You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit fdd8919
Browse filesBrowse the repository at this point in the historyBrowse files
fix(grid): stop hijacking the wheel, and stop rebuilding observers (#542)
Closes#407, #417.
## The wheel (#407)
Past 5000 rows the grid installed a non-passive wheel listener that called
preventDefault and moved scrollTop itself:
const SCROLL_BOOST = Math.min(totalRows / 100, 100);
el.scrollTop += e.deltaY * SCROLL_BOOST;
The multiplier came from the row count, which is not a property of the input
device. On a 10K-row result one notch of a mouse wheel travelled 10,000px,
about 312 rows, so the grid was unusable for finding anything. A trackpad
sends small pixel deltas many times a second and got the same treatment from
the other direction, feeling stuck. deltaMode, which is what actually says
whether a delta is in pixels, lines or pages, was never read.
Deleted. Native scrolling and the virtualizer already handle this between
them, and preventDefault on a non-passive listener was costing a main-thread
round trip per event to reimplement it worse.
## The observer (#417)
TruncatedCell's ResizeObserver effect listed `formatted` in its dependencies,
so every value change tore the observer down and constructed another. A grid
polling SELECT NOW(), or a column being typed into, does that for every
visible cell on every render.
Nothing leaked — the cleanup did disconnect them — so the issue's framing
overstates it. The cost is churn: hundreds of constructions a second all
doing the work of one, showing up as CPU burnt on an idle grid.
Split in two. The observer is created once per mounted cell and watches for
the box changing size. A second effect re-measures when the text changes,
which is a single layout read and what the original effect was really for.
`columnName` and `dataType` were dependencies too, and neither bears on
whether text overflows its box.
## Tests
- one browser test asserting no non-passive wheel listener is installed on a
5001-row result; React's own root registers a passive one, which by
definition cannot preventDefault, so the assertion targets the kind that
can
- three on observer churn: one observer across 25 value changes, one across
column-metadata changes, and still disconnected on unmount
The wheel test and the first two churn tests fail against the previous
implementation. The unmount test passes either way — it guards behaviour the
split could plausibly have broken, and did not.
Co-authored-by: Claude Opus 5 <[email protected]>
0 commit comments