Skip to content

Commit a63f19c

Browse files
PR Batch Testerclaude
andcommitted
fix(web): recheck table cells after every render
A cell that grows until it clips can leave the table the same size, so the resize observer alone missed it and the wrap button stayed hidden. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 9f56276 commit a63f19c

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

‎apps/web/src/components/ChatMarkdown.tsx‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -592,16 +592,23 @@ function MarkdownTable({ children, ...props }: React.ComponentProps<"table">) {
592592
const wrapLabel = expanded ? "Disable cell wrap" : "Wrap long cells";
593593
const copyLabel = copied ? "Copied" : "Copy table";
594594

595-
// Streaming rows, font loads, and column width changes all resize the table.
596-
useLayoutEffect(() => {
595+
const measureClippedCells = useCallback(() => {
597596
const container = containerRef.current;
598597
const table = tableRef.current;
599-
if (!container || !table) return;
600-
const measure = () => setHasClippedCells(tableHasClippedCells(container, table));
601-
measure();
602-
return observeResize(table, measure);
598+
if (container && table) setHasClippedCells(tableHasClippedCells(container, table));
603599
}, []);
604600

601+
// A streamed cell can grow until it clips while the table keeps its size,
602+
// so remeasure after every render, not only on resize.
603+
useLayoutEffect(measureClippedCells);
604+
605+
// Font loads and column width changes resize the table without a render.
606+
useLayoutEffect(() => {
607+
const table = tableRef.current;
608+
if (!table) return;
609+
return observeResize(table, measureClippedCells);
610+
}, [measureClippedCells]);
611+
605612
function toggleExpanded() {
606613
const table = tableRef.current;
607614
if (!table) return;

0 commit comments

Comments
 (0)