fix(webui): wrap markdown table content

This commit is contained in:
chengyongru authored and chengyongru committed 2026-09-22 16:22:51 +08:00
1 parent 144d17da61
commit 99a7ec256f
3 files changed
+17 -7

No files matched your search

@@ -714,11 +714,13 @@ export default function MarkdownTextRenderer({
>
<table
className={cn(
"w-full min-w-max border-collapse text-[13px] leading-5",
"w-full table-fixed border-collapse text-[13px] leading-5",
"[&_thead]:bg-muted/45 [&_thead]:text-muted-foreground",
"[&_th]:border-b [&_th]:border-border/65 [&_th]:px-3 [&_th]:py-2",
"[&_th]:text-left [&_th]:font-medium",
"[&_th]:text-left [&_th]:font-medium [&_th]:whitespace-normal",
"[&_th]:[overflow-wrap:anywhere]",
"[&_td]:border-b [&_td]:border-border/55 [&_td]:px-3 [&_td]:py-2",
"[&_td]:whitespace-normal [&_td]:[overflow-wrap:anywhere]",
"[&_th:not(:last-child)]:border-r [&_th:not(:last-child)]:border-border/45",
"[&_td:not(:last-child)]:border-r [&_td:not(:last-child)]:border-border/45",
"[&_tbody_tr:last-child_td]:border-b-0",
+3 -4
View File
@@ -717,10 +717,9 @@
display: inline;
}
/* Wide markdown tables scroll horizontally within the conversation column.
Tables are wrapped in an overflow-x:auto <div> by the markdown renderer's
custom `table` component (see MarkdownTextRenderer); min-w-max on the
<table> keeps natural column widths so it scrolls instead of shrinking. */
/* Markdown tables wrap cell text to fit the conversation column. The
renderer's overflow-x:auto wrapper remains a fallback for content that
cannot shrink. */
/* Clip any residual horizontal bleed at the thread column edge. Vertical
scrolling and internal code-block scroll are unaffected. */
@@ -483,7 +483,16 @@ describe("MarkdownTextRenderer", () => {
expect(surface).toHaveAttribute("role", "region");
expect(surface).toHaveAttribute("tabindex", "0");
expect(surface).toHaveAccessibleName("Data table");
expect(screen.getByRole("table")).toHaveTextContent("nanobot");
const table = screen.getByRole("table");
expect(table).toHaveTextContent("nanobot");
expect(table).not.toHaveClass("min-w-max");
expect(table).toHaveClass(
"table-fixed",
"[&_th]:whitespace-normal",
"[&_th]:[overflow-wrap:anywhere]",
"[&_td]:whitespace-normal",
"[&_td]:[overflow-wrap:anywhere]",
);
expect(container.firstElementChild).toHaveClass("space-y-4");
expect(container.firstElementChild).not.toHaveClass("space-y-0");
});