Repository navigation
Fix clicking a frozen cell scrolling the grid back - #4247
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Since #3963, the grid always set its scroll padding to the size of the frozen columns, header rows, and summary rows. Frozen cells, header cells, and summary cells are sticky and sit inside that padding, so focusing or scrolling them into view, e.g. when clicking an active frozen cell again, scrolled the grid until they were out of it, scrolling back to the start. Restore the conditional padding from before #3963: apply it only on the axes where the active cell isn't sticky, or when scrolling to a position. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4247 +/- ##
=======================================
Coverage 99.13% 99.13%
=======================================
Files 46 46
Lines 2195 2207 +12
Branches 968 977 +9
=======================================
+ Hits 2176 2188 +12
Misses 19 19
🚀 New features to boost your workflow:
|
nstepien
left a comment
There was a problem hiding this comment.
Out of curiosity:
- Why does this happen on the second click but not the first click?
- Can this be fixed without conditional scroll padding? I would expect browsers to not scroll the container when the element is already visible.
Co-authored-by: Nicolas Stepien <[email protected]>
…adding `isRowInViewport` and `isCellInViewport` aren't in scope in `DataGrid`, and `getActiveColumn()` throws when the active position isn't a cell, such as on the first render, so add `queryActiveColumn()` to `useActivePosition` and use the existing `activePositionIsInViewport`. Test focusing a frozen cell with the keyboard instead of double-clicking it, as Playwright scrolls the clicked element into view before clicking, which doesn't happen for users. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@nstepien thanks, answers to your questions:
On the first click on a new cell, Clicking the cell again when it's already active takes the With real mouse input in Chromium on
Firefox behaves as you'd expect and doesn't scroll. Chromium and WebKit treat the It can be fixed without conditional padding: when the element to scroll into view is a frozen cell, scroll its row instead. The row spans every column, so only the vertical scroll can change. In my tests, that fixed the frozen-column case in all three browsers, with the padding always on. But it doesn't cover the vertical version of the bug: double-clicking a header cell while scrolled down scrolls up through the always-on block padding. That would need "scroll horizontally only", and no element spans every row of a column. Conditional padding fixes both axes in one place, and matches the behavior before #3963, so I kept it. Happy to switch if you prefer the targeted approach. On your suggestion: as you mentioned, I also changed the test. It now focuses a frozen cell with ArrowDown after scrolling, instead of double-clicking. Playwright scrolls a clicked element into view before clicking, so on Generated with Claude Code |
|
Let me know if you have any other comments. I can create a follow up PR |
|
LGTM 👍 |
With `content-visibility: auto` on the nested grid, WebKit sizes the columns of its row wrongly until the next layout. Since #4247, activating a cell changes the scroll padding of the grid, so pressing the mouse triggers that layout. It moves the checkbox before the mouse is released, which loses the click. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Summary
Fixes a regression from #3963 in Chromium and WebKit: with frozen columns and the grid scrolled horizontally, clicking an already active frozen cell scrolls the grid back by the frozen columns' width. Each further click scrolls back again, until the horizontal scroll is gone. Double-clicking a frozen cell, and moving within a frozen column with the keyboard, do the same. Firefox isn't affected.
Cause
Frozen cells are
position: sticky. The grid setsscroll-paddingto the size of the frozen columns, so that ordinary cells scrolled into view don't end up hidden under them.scrollIntoViewon a frozen cell scrolls the grid. The cell is sticky, so it never leaves the strip, and every call scrolls again. Firefox doesn't scroll in this case.Why the second click, not the first
samePositionbranch ofsetPosition, which callsscrollIntoViewon the cell. A double-click hits it twice.scrollIntoView.Measured with real mouse input in Chromium on
main: the first click leavesscrollLeftat 1000, and each later click scrolls back exactly 100px, the frozen column's width.When it was introduced
The test was run against older versions of
src/(onlysrc/swapped, with today's tests and tooling):v7.0.0-beta.59173e7f7d, the commit before #396390a8fe8f(#3963)src/commit tested,v7.0.0-beta.60, andmainNone of the recent PRs are involved: the bug was already there in every commit since #4034.
Fix
Restore the conditional scroll padding, adapted to start- and end-frozen columns:
scrollToCell), as before.queryActiveColumn()is new inuseActivePosition. It returns the active column, orundefinedwhen the active position isn't a cell, for example on the first render.getActiveColumn()is now built on it, and still throws in that case.Ordinary cells still scroll out from under the frozen columns, header and summary rows, because the padding is present whenever an ordinary cell is active.
The same root cause also affected:
Both were checked with temporary tests and are fixed too.
Alternative considered
Keep the always-on padding, and when the element to scroll into view is a frozen cell, scroll its row instead. The row spans every column, so the browser only scrolls vertically. This fixed the frozen-column case in all three browsers. But it doesn't cover the vertical version of the bug, header and summary cells, because no element spans every row of a column. Conditional padding fixes both axes in one place, and matches the behavior before #3963.
Testing
New test in
test/browser/column/startFrozen.test.ts:scrollLeftto be unchanged.This goes through the app's own
scrollIntoViewcall, the same one a second click makes. It avoids clicking after scrolling, because Playwright scrolls a clicked element into view before clicking, which users don't experience.main, it fails in Chromium and WebKit (scrollLeft900 instead of 1000), and passes in Firefox, which isn't affected.Temporary checks (not committed), all passing with the fix:
scrollLeft;scrollTop.Full Chromium browser suite: passes, except 3 sorting tests that also fail on
mainon the same machine.vp check,vp run typecheckandvp packpass.🤖 Generated with Claude Code