fix(virtual-core): record the committed max as a clamp candidate #1330
Merged
piecykmerged 3 commits into
main fromrefs/pull/1330/head·merged by piecyk Showing 6 changed files with 44 additions and 38 deletions (loading 2).
x
@@ -0,0 +1,7 @@
+---
+'@tanstack/virtual-core': patch
+---
+
+fix(virtual-core): keep an instant scroll command clamped at a max the sizer committed outside a row resize
+
+Before an instant scroll command's write is reported, the browser can clamp it at a smaller scroll max that the sizer moves to without a row resize: an append or prepend, `measure()`, or a resize the sizer had not committed when the command was written. The virtualizer now also records the max at each commit, so such an event is read as its own clamped write and the command lands. A clamped write reported with `isScrolling` false is now written again too.
@@ -610,15 +610,16 @@
- // - `max`, `lowMaxes`: for a command's instant write, the scroll max as
- // rows measured since the write moved it (`resizeItem`), and each value
- // it took below `target`. The browser clamps the write to one of them
- // at a layout, and the sizer can grow back before the report, so the
- // read-back is that max rather than the element's current one.
+ // - `lowMaxes`: for a command's instant write, each scroll max below
+ // `target` the element had since the write. A command's target is
+ // clamped to the max at the write, but the sizer can shrink under it
+ // before the report (rows measured smaller, a count change) and grow
+ // back, so the read-back is the max the browser clamped to then rather
+ // than the element's current one. Read wherever the sizer can have