Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions apps/web/src/components/chat/ComposerBannerStack.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { renderToStaticMarkup } from "react-dom/server";
import { describe, expect, it } from "vite-plus/test";

import { ComposerBannerStack, type ComposerBannerStackItem } from "./ComposerBannerStack";

const banner = (id: string): ComposerBannerStackItem => ({
id,
variant: "warning",
icon: <span aria-hidden="true">!</span>,
title: `${id} warning`,
});

describe("ComposerBannerStack", () => {
it("keeps expanded banners in layout flow so surrounding content moves out of their way", () => {
const markup = renderToStaticMarkup(
<ComposerBannerStack items={[banner("front"), banner("stacked")]} />,
);

const expandedItems = markup.match(
/<div data-composer-banner-stack-expanded-items="true" class="([^"]+)">/,
);

expect(expandedItems?.[1]).toContain("grid-rows-[0fr]");
expect(expandedItems?.[1]).toContain("group-hover/banner-stack:grid-rows-[1fr]");
expect(expandedItems?.[1]).not.toContain("absolute");
expect(markup.indexOf("stacked warning")).toBeLessThan(markup.indexOf("front warning"));
});

it("does not render an expandable region for a single banner", () => {
const markup = renderToStaticMarkup(<ComposerBannerStack items={[banner("front")]} />);

expect(markup).not.toContain("data-composer-banner-stack-expanded-items");
});
});
65 changes: 37 additions & 28 deletions apps/web/src/components/chat/ComposerBannerStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,43 @@ export function ComposerBannerStack({ className, items }: ComposerBannerStackPro
aria-hidden="true"
/>
) : null}
{hasStack ? (
<div
data-composer-banner-stack-expanded-items="true"
className={cn(
"grid grid-rows-[0fr] transition-[grid-template-rows] duration-150 ease-out",
"group-hover/banner-stack:grid-rows-[1fr] group-focus-within/banner-stack:grid-rows-[1fr]",
)}
>
<div className="min-h-0 overflow-hidden">
<div
className={cn(
"pointer-events-none space-y-2 pb-2 opacity-0",
"translate-y-1 transform-gpu transition-[opacity,transform] duration-150 ease-out will-change-[opacity,transform]",
"group-hover/banner-stack:pointer-events-auto group-hover/banner-stack:translate-y-0 group-hover/banner-stack:opacity-100",
"group-focus-within/banner-stack:pointer-events-auto group-focus-within/banner-stack:translate-y-0 group-focus-within/banner-stack:opacity-100",
)}
>
{stackedItems.map((item) => (
<div
key={item.id}
className={cn(exitingItemId === item.id ? "pointer-events-none" : null)}
style={{
...exitTransitionStyle,
...(exitingItemId === item.id ? stackedExitStyle : restingStyle),
}}
>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stacked dismiss animation clipped

Low Severity

Stacked composer banners dismiss with a large downward translate3d, but those alerts now sit inside the grid collapse wrapper that uses min-h-0 overflow-hidden. Transforms do not expand that box, so the exit motion is cut off while opacity fades. The version-mismatch dismiss looks broken compared with the front banner, which is not inside that clip.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 0507e3c. Configure here.

<ComposerBannerStackAlert
item={item}
exiting={exitingItemId === item.id}
onDismissRequest={() => requestDismiss(item)}
/>
</div>
))}
</div>
</div>
</div>
) : null}
<div
className={cn(
"relative z-10",
Expand All @@ -117,34 +154,6 @@ export function ComposerBannerStack({ className, items }: ComposerBannerStackPro
onDismissRequest={() => requestDismiss(frontItem)}
/>
</div>
{hasStack ? (
<div
className={cn(
"pointer-events-none absolute inset-x-0 bottom-[calc(100%+0.5rem)] z-20 space-y-2 opacity-0",
"transition-[opacity,transform] duration-150 ease-out",
"translate-y-1 transform-gpu will-change-[opacity,transform]",
"group-hover/banner-stack:pointer-events-auto group-hover/banner-stack:translate-y-0 group-hover/banner-stack:opacity-100",
"group-focus-within/banner-stack:pointer-events-auto group-focus-within/banner-stack:translate-y-0 group-focus-within/banner-stack:opacity-100",
)}
>
{stackedItems.map((item) => (
<div
key={item.id}
className={cn(exitingItemId === item.id ? "pointer-events-none" : null)}
style={{
...exitTransitionStyle,
...(exitingItemId === item.id ? stackedExitStyle : restingStyle),
}}
>
<ComposerBannerStackAlert
item={item}
exiting={exitingItemId === item.id}
onDismissRequest={() => requestDismiss(item)}
/>
</div>
))}
</div>
) : null}
Comment thread
cursor[bot] marked this conversation as resolved.
Comment thread
cursor[bot] marked this conversation as resolved.
</div>
</div>
);
Expand Down
Loading