fix(files): restore horizontal scroll in CSV and XLSX preview tables … · simstudioai/sim@bd91ab7 · GitHub
Skip to content

Commit bd91ab7

Browse files
authored
fix(files): restore horizontal scroll in CSV and XLSX preview tables (#6550)
* fix(files): restore horizontal scroll in CSV and XLSX preview tables #6125 moved the preview tables onto the markdown table chrome and gave both surfaces `width: 100%`. That is right for prose and wrong for data: a CSV with dozens of columns divides the frame between them, and since the same change added `overflow-wrap: anywhere`, every column was free to break down to a single character — so headers rendered as vertical columns of letters and the table never exceeded its frame, leaving `overflow-x-auto` with nothing to scroll. Split sizing out of the shared rule. Prose tables keep `width: 100%`; preview tables size to their content and scroll, with column bounds so no column collapses to a sliver and one long value wraps instead of pushing the rest off-screen. Chrome (borders, padding, typography, header fill) stays shared. * fix(files): scroll preview tables from one container, not two nested ones DataTable owned `overflow-x-auto` while its caller owns the vertical scroll, so now that preview tables are actually wider than the frame the horizontal scrollbar rendered at the foot of the table rather than at the bottom of the viewport — up to 1,000 rows below it for the two callers whose container is a plain block (xlsx-preview, preview-panel). csv-table-preview escaped it only because its flex column compressed the wrapper to the frame height. Drop the inner overflow so the caller's bounded container scrolls both axes. All three callers now place the scrollbar at the viewport bottom. * fix(files): correct a stale reference to the removed inner overflow The sizing comment still credited `.document-table`'s own `overflow-x-auto` for the horizontal scroll, which the previous commit removed in favour of the caller's container.
1 parent b879960 commit bd91ab7

3 files changed

Lines changed: 55 additions & 4 deletions

File tree

‎apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/data-table.tsx‎

Lines changed: 5 additions & 1 deletion

‎apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/document-table.css‎

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
* Canonical table chrome for the file viewer. Both surfaces that render a table for a file — the
33
* rich markdown editor (`.rich-markdown-prose table`) and the tabular previews CSV/XLSX render
44
* through `DataTable` (`.document-table`) — share this one definition so a table looks the same
5-
* whichever file it came from. Editor-only concerns (prose block margin, fixed layout for column
6-
* resizing, cell paragraph reset) stay in rich-markdown-editor.css.
5+
* whichever file it came from. Chrome is shared; *sizing* is not — prose fits the document width
6+
* while a preview sizes to its data and scrolls (see the two rules below). Editor-only concerns
7+
* (prose block margin, fixed layout for column resizing, cell paragraph reset) stay in
8+
* rich-markdown-editor.css.
79
*/
810

911
/* `overflow-wrap` matches what `.rich-markdown-prose` sets on its own root: cells hold arbitrary
@@ -15,11 +17,34 @@
1517

1618
.rich-markdown-prose table,
1719
.document-table table {
18-
width: 100%;
1920
border-collapse: collapse;
2021
overflow: hidden;
2122
}
2223

24+
.rich-markdown-prose table {
25+
width: 100%;
26+
}
27+
28+
/* A preview table is data, not prose. A CSV can carry dozens of columns, so sizing the table to the
29+
frame (`width: 100%`) divides that frame between them and — with `overflow-wrap: anywhere` able to
30+
break every column down to one character — renders each header a vertical column of letters.
31+
`max-content` sizes columns to their values and lets the table exceed the frame, which the
32+
caller's own scroll container then scrolls; `min-width: 100%` keeps a narrow table filling the
33+
frame rather than hugging the left edge. */
34+
.document-table table {
35+
width: max-content;
36+
min-width: 100%;
37+
}
38+
39+
/* Bounds for a content-sized column: no column collapses to a sliver, and one long value (a URL, a
40+
pasted paragraph) wraps at `max-width` instead of pushing every other column off-screen. 80px is
41+
the tables grid's own `COL_WIDTH_MIN`; 320px is the capped content width used across the app. */
42+
.document-table th,
43+
.document-table td {
44+
min-width: 80px;
45+
max-width: 320px;
46+
}
47+
2348
.rich-markdown-prose th,
2449
.rich-markdown-prose td,
2550
.document-table th,

‎apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/document-table.test.ts‎

Lines changed: 22 additions & 0 deletions

0 commit comments

Comments
 (0)