diff --git a/apps/web/src/components/chat/ThreadErrorBanner.test.tsx b/apps/web/src/components/chat/ThreadErrorBanner.test.tsx new file mode 100644 index 00000000000..73e4c08fc88 --- /dev/null +++ b/apps/web/src/components/chat/ThreadErrorBanner.test.tsx @@ -0,0 +1,23 @@ +import { renderToStaticMarkup } from "react-dom/server"; +import { describe, expect, it } from "vite-plus/test"; + +import { ThreadErrorBanner } from "./ThreadErrorBanner"; + +describe("ThreadErrorBanner", () => { + it("aligns the warning and dismiss icons with the first line of a multi-line error", () => { + const markup = renderToStaticMarkup( + {}} + />, + ); + + expect(markup).toContain('role="alert"'); + expect(markup).toContain('aria-label="Dismiss error"'); + expect(markup).not.toContain("controlAlignment"); + expect(markup).toContain("flex gap-2 items-start"); + expect(markup).toContain("min-h-7 pt-1 sm:min-h-6 sm:pt-0.5"); + expect(markup).toContain("h-lh w-4"); + expect(markup).toContain("h-lh self-start"); + }); +}); diff --git a/apps/web/src/components/chat/ThreadErrorBanner.tsx b/apps/web/src/components/chat/ThreadErrorBanner.tsx index 51bfb62667d..4ec25b574ae 100644 --- a/apps/web/src/components/chat/ThreadErrorBanner.tsx +++ b/apps/web/src/components/chat/ThreadErrorBanner.tsx @@ -14,7 +14,7 @@ export const ThreadErrorBanner = memo(function ThreadErrorBanner({ if (!error) return null; return (
- + diff --git a/apps/web/src/components/ui/alert.tsx b/apps/web/src/components/ui/alert.tsx index 20be44dd3e5..0af4020971e 100644 --- a/apps/web/src/components/ui/alert.tsx +++ b/apps/web/src/components/ui/alert.tsx @@ -42,9 +42,13 @@ function alertChildSlot(child: React.ReactElement): string | undefined { function Alert({ className, variant, + controlAlignment = "center", children, ...props -}: React.ComponentProps<"div"> & VariantProps) { +}: React.ComponentProps<"div"> & + VariantProps & { + controlAlignment?: "center" | "first-line"; + }) { const icon: React.ReactNode[] = []; const content: React.ReactNode[] = []; const action: React.ReactNode[] = []; @@ -71,9 +75,24 @@ function Alert({ role="alert" {...props} > -
+
0 && + "min-h-7 pt-1 sm:min-h-6 sm:pt-0.5", + )} + > {icon.length > 0 && ( -
+
svg]:size-4" + : "size-4 [&>svg]:size-full", + )} + > {icon}
)} @@ -81,7 +100,14 @@ function Alert({
{content}
)} {action.length > 0 && ( -
{action}
+
+ {action} +
)}