Repository navigation
feat(grid): freeze the first data column while scrolling horizontally - #1234
Conversation
Code Review SummaryStatus: No Issues Found | Recommendation: Merge This update adds one commit ( I checked the new test against the implementation. With a measured gutter of 100px, the frozen header and cells get Assumption: I did not run the tests or the visual behavior. The PR notes it was only verified in Chrome, so a quick check in WebKitGTK and WebView2 is worthwhile. Files Reviewed (16 files)
Previous Review Summaries (3 snapshots, latest commit 0c261d0)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 0c261d0)Status: No Issues Found | Recommendation: Merge This update rebases onto the I checked the stacking: the gutter body cell is Assumption: I did not run the visual behavior. The PR notes it was only verified in Chrome, so a quick check in WebKitGTK and WebView2 is worthwhile. Files Reviewed (16 files)
Previous review (commit d51fe99)Status: No Issues Found | Recommendation: Merge This update is a rebase onto the Prettier formatting commit ( Assumption: the visual behavior (the 1px gutter-edge overlap on cells that use Files Reviewed (16 files)
Previous review (commit 965b5f1)Status: No Issues Found | Recommendation: Merge Reviewed the freeze-first-column change (sticky header/cells with opaque Assumption: the visual behavior (the 1px gutter-edge overlap on cells that use Files Reviewed (16 files)
Reviewed by claude-sonnet-5.5 · Input: 252 · Output: 2K · Cached: 305.1K Review guidance: REVIEW.md from base branch |
965b5f1 to
d51fe99
Compare
Preview buildThe preview build of commit |
debba
left a comment
There was a problem hiding this comment.
Thanks for this, it's a feature people have been asking for! Keeping the layout and background logic in pure helpers (getFrozenFirstColumnLayout, getFrozenCellBackdropClass) with direct tests makes it easy to review. The backdrop follows the same row precedence as DataGridRow (selected, then insertion, pending delete, zebra and hover). The scroll-padding-left, so arrow keys don't park the active cell under the frozen column, is a nice detail.
I'm requesting changes only for the rebase: #676 moved the frontend to packages/web-ui/src and the tests to packages/web-ui/tests. The code you touch hasn't changed on main, so once the paths are rewritten the hunks apply cleanly, and the DataGrid tests pass on the rebased tree.
Nits for a follow-up:
- Looking closely at your
after-frozen-dark.png, I think there's a 1px strip of scrolled text showing at the edge between the row number column and the frozen column (rows 3, 4 and 12), so thebefore:-left-pxcover may not fully close the gap. Could you check it in the real app (WebKitGTK/WebView2)? The description says it hasn't been run there yet. - The focused frozen cell uses
outline-accent-primary, butaccessibility.mdanddesign.mdwantoutline-focusfor focus. The existing non-frozen ring usesaccent-primarytoo, so switching both would be great. - Before the widths are measured,
scrollPaddingLeftis only 50, so in the very first frame keyboard navigation could still hide a cell. It's very short-lived. - The frozen state survives a new query in the same tab, since it's plain
useState. That's fine, but worth mentioning in the PR.
d51fe99 to
0c261d0
Compare
|
Thanks for the review, @debba. Rebased onto 1px strip at the gutter edge. You were right, and it was the collapsed border. With
Frozen state across queries. It's plain Full web-ui vitest run: 456 files, 7162 tests pass. Prettier, eslint, the theme-token check and |
debba
left a comment
There was a problem hiding this comment.
Thanks for the rebase and for tracking down the 1px strip properly. Pulling the frozen cell under the collapsed gutter border is a much cleaner fix than another pseudo-element tweak, and the zoomed before/after in the description made it easy to see what changed.
Everything now sits under packages/web-ui, it still merges cleanly with current main, and the grid and helper tests pass on my side (312, all 13 new freeze cases included). Build, eslint, prettier and the theme token check are clean too. The stacking checks out: the gutter cells stay above the frozen column, so the 1px overlap stays hidden. The note about the frozen state surviving a new query is fine.
I'm approving this. The leftovers are fine as follow-ups, as we said:
- switch the focus mark to the
focustoken, both the frozen outline inDataGridRow.tsxand the existing ring - the 50px scroll padding before the column widths are measured
- the translucent gutter on selected rows, if you still feel like sending that one
Since you only had Chrome, I'll run it in the desktop app on my side before merging, mainly to look at the gutter edge and at editing a frozen cell.
|
@Detoy I merged a batch of approved PRs tonight, and #1222 (column resize with mouse and keyboard) went in just before yours, so this branch now conflicts with The overlap is real but contained, in four files: When you rebase, could you also check that resizing the frozen first column keeps the frozen offset and the scroll padding in sync with the new width? That's the one interaction neither PR could test before. My approval stands. Once it's rebased and green I'll merge it. |
Adds a grid-local Freeze first column / Unfreeze first column toggle to the column header context menu (TabularisDB#1152). The frozen header and cells are sticky right after the row-number gutter, on an opaque backdrop that repeats the row background (selection, insertion, pending delete, zebra, hover) so scrolled cells don't show through. Keyboard navigation keeps the active cell clear of the frozen column through scroll padding, and focusing or editing a frozen cell no longer scrolls back to the start.
…trip of scrolled text shows
The frozen header keeps the resize handle from TabularisDB#1222: sticky is already the handle's containing block, so the frozen header is not also made relative. Resizing the frozen column leaves its sticky offset at the gutter edge and moves the scroll padding with the new width.
0c261d0 to
9ba84d2
Compare
|
Rebased onto
Full vitest run: 459 files, 7336 tests pass. |
There was a problem hiding this comment.
Thanks for handling the overlap with column resizing. The frozen header stays sticky without also becoming relative, and the drag/keyboard test covers the interaction I asked for. The grid and helper suites pass (328 tests), along with typecheck and the frontend checks from my earlier review.
I have now tried the PR in the real macOS app against a wide SQLite table. With the grid scrolled 400px right, dragging the frozen column from about 110px to 190px keeps its left edge at the gutter and changes scroll padding from about 160px to 240px. Shift+ArrowLeft reduces it to 140px with 190px padding. Unfreezing clears the sticky position and padding. Editing the frozen text primary key and clicking Submit persisted the new value in SQLite.
I checked Dark, Light and High Contrast. The frozen cell stays opaque; the existing selected-row gutter issue is visible in Light and High Contrast.
Approved, with these follow-ups:
- Use the focus token for the frozen outline and the existing focus ring.
- Revisit the fallback scroll padding before widths are measured.
- Make the selected-row gutter opaque.
- Opening the frozen cell's inline editor through a double-click jumps horizontally from
scrollLeft=400to0in WKWebView. I repeated that three times with the same result. The edit still saves correctly, so I see this as a scroll/focus follow-up rather than a data-correctness blocker.
The native checks are complete.
Closes #1152
Problem
The row-number gutter is already sticky, but the first data column scrolls away with the rest. On a wide result you lose the identifier (
id, a code, an email) as soon as you scroll right to read the other columns.Fix
Toggle. The column header context menu gets Freeze first column / Unfreeze first column (Pin / PinOff icon), next to Select Column. It's grid-local
useStateinDataGrid: one column only, nothing persisted, off by default.Sticky offsets (
getFrozenFirstColumnLayout, pure)position: stickywithleft= the gutter's width minus its 1px shared border, read from the column widths the grid already measures and locks (50px until they're measured, soleft: 49px). That keeps the header, cells and gutter aligned under horizontal and vertical scrolling.border-collapse, the border between the gutter and the first column is painted by the table where the column started, outside the sticky cell's own painting. Atleft= gutter width, a 1px column of scrolled text showed through that strip. Pulling the frozen cell 1px under the gutter covers it.z-[5](above scrolling cells, below the gutter'sz-10), headerz-[15](below the gutter header'sz-20).Opaque backdrop (
getFrozenCellBackdropClass, pure)::beforeis the row background pre-mixed over the grid background (color-mix(... var(--bg-elevated))with the same token and percentage as the row: selected, insertion, pending delete, zebra, and the hover tints). It mirrors the row's class precedence.::afterisbackground-color: inherit, which repaints the cell's own tint (edited, column or range selection) on top.::before(inset-0) also draws the frozen column's right border.Editing and focus
position: relativeto anchor the inline editor. A frozen cell skips that (sticky already anchors it), so it stays frozen while you edit.Keyboard navigation
scroll-padding-left= gutter + frozen column width, soscrollIntoViewstops the active cell to the right of the frozen column, where it was otherwise hidden under it.scrollLeftfor the frozen column, and its editor is focused withpreventScroll.Column resizing (#1222)
relativeso the resize handle can sit inside it. The frozen header isstickyinstead, which is already the handle's containing block, so it keeps its handle and the two classes don't fight overposition.leftis the gutter width, which resizing never changes. Its scroll padding is computed from the locked widths, so it follows the new width when a resize is committed (mouse up or a key press). During a drag only the<col>width is painted, and the sticky cell follows it.Screenshots
Component preview in Chrome: the real
DataGridwith simulated rows, a selected row (2), a pending edit (row 3) and zebra stripes, scrolled right.Manual wide-result check in that preview (Chrome, measured with
getBoundingClientRect): the frozen header and cells sit at 50–164px at every horizontal and vertical scroll position. Scrolled right, walking ArrowLeft from column 8 to column 1 always leaves the focused cell to the right of the frozen column. Clicking, ArrowDown in and double-clicking the frozen cell all keepscrollLeftat 400.Gutter edge, 6× zoom (left:
d51fe99f,left= gutter width; right: this branch). A pixel check that diffs screenshots with and without the scrolled cells' text, at 5 scroll positions in both themes, went from 564 leaked device pixels to 150. The remaining 150 all come from the selected row's translucent gutter described below, which is the same onmain.Testing
packages/web-ui/tests/utils/dataGrid.test.ts: 7 cases for the offsets (fallback and measured widths) and the backdrop (default, zebra, precedence of selected > insertion > pending delete, no hover tint on those states, tint layer present).packages/web-ui/tests/components/ui/DataGrid.test.tsx, newDataGrid freeze first column (#1152)block, 6 cases: freeze and unfreeze from the header menu (only column 0 gets sticky,left: 49px), scroll padding on and off, a frozen cell stays sticky while edited, its editor is focused withpreventScroll, focusing it keepsscrollLeft, and the outline focus mark.main39dab01 (after feat(grid): resize columns with the mouse and keyboard #1222 added column resizing). Both sides of the helper and test conflicts are kept. New test in the#1151resizing block: a frozen first column keeps its resize handle (sticky, not relative), and dragging or arrow-keying it keepsleftat the gutter edge whilescroll-padding-leftfollows the new width. I checked it fails if the frozen header is alsorelative.vitest run --config packages/web-ui/vitest.config.ts: 459 files, 7336 tests pass.tsc -b, Prettier and eslint on the changed files, and the theme token check are clean.MemoRowis only rendered byDataGrid, andRowCtxgains one field. With the toggle off, the cells, header and scroll container render the same classes as on main. The only shared-path change is the edit-focus effect, which now passes{ preventScroll: false }(the default) for every cell that isn't frozen. No backend change, 2 new strings in all 11 locales.Plugin drivers
Driver-independent: it only changes how the loaded result set is rendered, so it behaves the same for every built-in and plugin driver.
Not in this PR
bg-accent-primary/20), so scrolled text still shows faintly through the gutter of a selected row (visible in both Before and After). I left that alone; happy to send a follow-up if you want it opaque too.useStateinDataGrid, so it survives running a new query in the same tab (the grid isn't remounted). It resets when the tab closes.scroll-padding-leftuses the 50px fallback until the widths are measured, i.e. for the first frame only.outline-accent-primary, like the existing non-frozen ring; switching both tooutline-focusis left for a follow-up.AI disclosure: I built this with AI assistance (Grok Bot) and reviewed the diff, tests and screenshots before opening the PR.