mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-20 06:51:59 +00:00
🌫️ fix: Keep the Question Card's Bottom Edge Free of an Inner Shadow (#18538)
* fix: Keep the Question Card's Bottom Edge Free of an Inner Shadow * test: Assert the Question Card Leaves No Shadow Band Above the Composer
This commit is contained in:
parent
1ff56a9f65
commit
f7ae4c8e10
2 changed files with 47 additions and 2 deletions
|
|
@ -128,6 +128,18 @@ const answerField = (scope: Scope, question: string) =>
|
|||
const optionRow = (scope: Scope, name: string) =>
|
||||
scope.getByRole('button', { name: new RegExp(`${escapeRegExp(name)}$`) });
|
||||
|
||||
/** How far a computed `box-shadow` reaches below its element: the largest y offset plus blur plus
|
||||
* spread over its outer layers. An inset layer paints inside the box and reaches nothing. */
|
||||
const shadowReach = (boxShadow: string): number =>
|
||||
boxShadow
|
||||
.split(/,(?![^(]*\))/)
|
||||
.filter((layer) => !layer.includes('inset'))
|
||||
.reduce((reach, layer) => {
|
||||
const lengths = layer.replace(/\([^)]*\)/g, '').match(/-?\d*\.?\d+/g) ?? [];
|
||||
const [, y = 0, blur = 0, spread = 0] = lengths.map(Number);
|
||||
return Math.max(reach, y + blur + spread);
|
||||
}, 0);
|
||||
|
||||
test.describe('ask question batch refinements', () => {
|
||||
test('Enter in an answer field confirms the step instead of sending the composer @scenario:ask-batch-enter-confirms-answer', async ({
|
||||
page,
|
||||
|
|
@ -352,6 +364,39 @@ test.describe('ask question batch refinements', () => {
|
|||
}
|
||||
});
|
||||
|
||||
test('the batch card leaves no shadow band between it and the composer @scenario:ask-batch-card-leaves-no-shadow-band', async ({
|
||||
page,
|
||||
}) => {
|
||||
test.setTimeout(120000);
|
||||
const label = `${Date.now()}-${Math.floor(Math.random() * 1e4)}`;
|
||||
let agentId: string | undefined;
|
||||
|
||||
try {
|
||||
const agent = await createAgent(page);
|
||||
agentId = agent.id;
|
||||
await openBatch(page, agent, label);
|
||||
const popover = await openPopover(page);
|
||||
const surface = page.getByTestId('composer-surface');
|
||||
|
||||
/* The card floats a small gap above the composer. A shadow that reaches further than that
|
||||
gap never fades out inside it: the whole strip stays tinted and reads as a dark band
|
||||
under the card's own border. */
|
||||
const slack = async () => {
|
||||
const [card, composer, boxShadow] = await Promise.all([
|
||||
popover.boundingBox(),
|
||||
surface.boundingBox(),
|
||||
popover.evaluate((element) => getComputedStyle(element).boxShadow),
|
||||
]);
|
||||
expect(card).not.toBeNull();
|
||||
expect(composer).not.toBeNull();
|
||||
return composer!.y - (card!.y + card!.height) - shadowReach(boxShadow);
|
||||
};
|
||||
await expect.poll(slack, { timeout: 5000 }).toBeGreaterThanOrEqual(0);
|
||||
} finally {
|
||||
await cleanupAgent(page, agentId);
|
||||
}
|
||||
});
|
||||
|
||||
test('a typed answer deselects the option and locks the rows until cleared @scenario:ask-typed-answer-locks-options', async ({
|
||||
page,
|
||||
}) => {
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ function QuestionPanel({
|
|||
return (
|
||||
<div className="absolute bottom-full z-10 mb-2 w-full">
|
||||
<div
|
||||
className="popover border-border-light bg-surface-secondary rounded-theme-popover flex max-h-[60vh] flex-col border p-2 shadow-lg [view-transition-name:ask-question]"
|
||||
className="popover border-border-light bg-surface-secondary rounded-theme-popover flex max-h-[60vh] flex-col border p-2 shadow-sm [view-transition-name:ask-question]"
|
||||
onKeyDown={(e) => {
|
||||
if (isCancelKey(e.nativeEvent) && !e.nativeEvent.isComposing) {
|
||||
e.preventDefault();
|
||||
|
|
@ -266,7 +266,7 @@ export default function AskPopover({
|
|||
<div className="absolute bottom-full z-10 mb-2 w-full">
|
||||
{/* The prompt and answers scroll within their own caps; this outer cap keeps the card on
|
||||
screen when both are at their limit on a short viewport. */}
|
||||
<div className="popover border-border-light bg-surface-secondary rounded-theme-popover flex max-h-[70vh] flex-col overflow-y-auto border shadow-lg [view-transition-name:ask-question]">
|
||||
<div className="popover border-border-light bg-surface-secondary rounded-theme-popover flex max-h-[70vh] flex-col overflow-y-auto border shadow-sm [view-transition-name:ask-question]">
|
||||
{renderQuestions({
|
||||
liveAsk,
|
||||
questions: liveAsk.questions,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue