Repository navigation
Fixed table column widths and column resizing - #3457
benjaminleonard wants to merge 19 commits into
Conversation
The table's outer border used to be painted by the edge cells, with ::after overlays faking the rounded corners. When a table without a sticky actions column overflowed, its right edge scrolled away and the border was left open. - Draw the border with a frame element pinned to the visible part of the scroller (sticky, sized with 100cqw), so it stays closed at any scroll position. Edge cells keep transparent 1px borders so column widths match. - Replace simplebar-react with a native scrollbar styled to match (::-webkit-scrollbar, scrollbar-color in Firefox), keeping 16px below the table whether or not it overflows. - Remove the corner overlays and !important overrides from table.css. - Draw row selection as one outline per row, merging adjacent rows with :has(), instead of box-shadow hacks on every cell. Removes the cloneElement pass in Table.Body. - Fade sticky column shadows in and out with scroll-state container queries where supported, falling back to the scroll-driven animations. Tables with no actions column get a matching shadow at the right edge while there's more to scroll to. - Table's className now applies to the outer box, so sizing classes like max-w-lg size the frame too. - Add narrow-viewport overflow cases to the visual regression suite. Not pixel-identical to before: two old quirks (no left border on the bottom-left cell, -m-px on last-column cells) skewed column widths, so some columns shift by a fraction of a pixel, and two-column tables are 1px taller.
- Set overscroll-behavior-y: none on html as well as body so the app shell never rubber-bands, whichever element the browser treats as the viewport - Use overscroll-contain on side modal, modal and sidebar scrollers so they keep their native end-of-content bounce without chaining to the page - Disable overscroll entirely on menus, dropdowns and popovers, where a bounce on a small floating panel looks broken
Tables used auto layout, so columns resized themselves between pages and as async cells loaded. Every column now has a set width and the table uses fixed layout, so widths no longer depend on content. - Table renders a colgroup from meta.width. 'flex' columns share the space left over, and plain-text cells and headers truncate. - createColumnHelper in ~/table/column-helper requires meta.width on every column, and lint blocks importing TanStack's own. - New shared Columns helpers carry widths for the common kinds of column. - Columns can be resized by dragging header edges, and reset with a double-click. Sizes live in a zustand store keyed by table, kept across navigation but not persisted. - Snapshots: description moved after created.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- useTable and useQueryTable require an id, which keys each table's widths in the sizing store. Tables no longer share sizes just because they have the same columns. - Resizing uses its own drag code. A dragged column becomes fixed, from min 96px to max 3x the average column width. Once no flexible column is left, the spare width is split evenly between the columns nobody has dragged, measured from the scroll container. - The handle is positioned against the th so the bar sits flush with the divider on every column, not only the sticky first one. - Silo Quotas, System Utilization and the internet gateway routes table now use TanStack. - useTable defaults autoResetPageIndex to false. Pagination is server-side, and the reset looped forever when data was derived during render (e.g. Silo Quotas froze on opening Edit quotas).
|
@claude review |
There was a problem hiding this comment.
Findings marked 🟡 are optional suggestions and need no follow-up push.
Additional findings (outside the current diff — GitHub can't attach inline comments there):
-
🟡
app/table/Table.tsx— A resize drag can get stuck: after a cancelled touch or a right-click, the column keeps following the pointer and the table stays in resizing mode.startResizehandles any mouse button and listens only formouseup/touchend, so it never ends when those events don't arrive. Fix: make every drag end reliably. Start only on a primary-button press (e.button === 0) and end ontouchcancelas well. Pointer events withsetPointerCapturepluspointercancel/lostpointercapturewould cover all of these cases.Why this was flagged
The ResizeHandle's onMouseDown/onTouchStart (Table.tsx:147-148) call
startResize(Table.tsx:261) without checking which button was pressed. It adds a documentmousemove/touchmovelistener and removes it only inonEnd, which runs onmouseup/touchend(Table.tsx:275-285). When the OS cancels a touch (a system gesture, an incoming call, a multi-touch interruption),touchcancelfires instead oftouchend. Likewise, a right-click or macOS ctrl-click on the handle opens the native context menu, which can swallow themouseup. In both cases the listeners stay attached andcolumnSizingInfo.isResizingColumnstays set. The table keeps theox-table-resizingclass (col-resize cursor, user-select: none). The next pointer movement anywhere on the page resizes that column relative to the stalestartX, until some later mouseup or touchend. This handle is new in this PR, so the base branch has no such stuck state.Verification: Severity: nit. In app/table/Table.tsx, lines 147-148 start a resize on any mouse button, and lines 127-130 listen only for mouseup/touchend, with no touchcancel handler. If the context menu swallows mouseup or a touch is cancelled, the column width tracks the pointer (lines 122-126) and
ox-table-resizingstays (line 175). This is new code; the next mouseup or touchend recovers.
Badges in cells shrink and ellipsize within their padding and ring rather than being clipped at the cell edge. State badges wrap their text so it can show an ellipsis, and a trailing-badge class keeps a few characters of a name before the badge beside it gives way. Cells now use the same padding on both sides.
…actions On wide screens, flexible columns stop at 480px and an empty spacer column takes the rest, so every column renders at its own width and dragging one no longer redistributes the others. Resize observer updates flush before paint so shrinking the window doesn't flash a scrollbar.
The content gutter grows past --content-max-width instead of each page capping itself, so full-bleed tabs, dividers, and the page footer line up with the centered content. Registered with @Property so it resolves against the content pane rather than nested containers.
This reverts commit 41f9b14, which now lives on content-max-width.
Name columns scroll the table before going below 224px, and descriptions grow into spare room but never below their old fixed 240px. Fixed layout ignores minimums when sharing space, so columns whose even share would fall short are pinned at their minimum. Also widens the custom router column, fixes model number at 224px, and gives VPC subnet IP blocks room for IPv6.
- Use one module-level default column so plain-text cells keep their ellipsis and headers their tooltip after a re-render. TanStack rebuilds its own defaults whenever defaultColumn changes identity. - Render plain-text link and button cells through Truncate so cut-off names get a tooltip. - Keep the last column's resize handle inside the table so tables that fit don't scroll by a few px. - Resize with pointer capture, ending on lostpointercapture, and ignore secondary clicks, so a drag can't get stuck. - Match the Pool field exactly or within its dialog in e2e tests, since pool names in tables now carry an aria-label.
| } from '@tanstack/react-table' | ||
| import { create } from 'zustand' | ||
|
|
||
| /** Keyed by table (see `useTable`). Not persisted on purpose: a refresh resets widths. */ |
There was a problem hiding this comment.
We might decide to revisit this, but seems much simpler
Widths live on the colgroup, so the body only needs to re-render when rows, columns, or the spacer change. On a 1000-row table this cut a window resize frame from ~214ms to ~63ms of main-thread time (same as main) and a column drag move from ~189ms to ~36ms. Also memoizes columns on the snapshots and affinity pages, which rebuilt them every render and so re-rendered every row.
Currently column widths are inferred from content so you end up with tables that dance around during pagination or when cells load content async. This sets column widths as part of the column meta and gives the user the ability to adjust the column widths with a little handle on the header.
Example of cell pop-in this PR fixes:

Tablerenders a<colgroup>and usestable-layout: fixed, so widths come only from the column defs.meta.width, not TanStack'ssize.sizedefaults to 150, so it can't mark a column as flexible.meta.width: 'flex'shares whatever space the fixed columns leave. That's usually the name column.min-widthis the sum of the fixed widths plus 160px for each flexible column. Below that, the table scrolls instead of squashing.ColWidthinapp/table/columns/common.tsx(xs96 …xl208, plusdate,description,idandip), so the same kind of column is the same width on every table.Columnswithout anyone choosing one. New helpers:ipVersion,poolType,diskType,diskState,diskSource,instance(tab),imageOs,imageVersion,identityTypeandserial, alongside the existingtimeCreated,description,idandsize.Every column must have a width, and we wrap the
createColumnHelperto requiremeta.widthwithtsc. Groups are exempt because they take their width from their child columns.Column resizing
Screenshots