{{ message }}
Repository navigation
fix(virtual-core): clamp tracked scrollOffset at 0 in end-anchor compensation - #1230
Merged
piecyk merged 1 commit intoJul 17, 2026
Merged
Conversation
…ensation With anchorTo: 'end' and element scrolling, measurement compensation (applyScrollAdjustment) and the setOptions edge-key re-anchor wrote the tracked scrollOffset without clamping to the reachable range. When items measured smaller than their estimates and the content was shorter than the viewport, the offset went negative with no scroll event ever able to correct it (an unscrollable element emits none), permanently skewing getDistanceFromEnd()/isAtEnd() and wedging _flushIosDeferredIfReady so iOS deferred measurement corrections never flushed. Clamp only the lower bound: upper-bound overflow is transiently legitimate mid-prepend while the consumer's sizer catches up, but a negative element offset is invalid unconditionally. Fixes TanStack#1229 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
View your CI Pipeline Execution ↗ for commit 3f963ae
☁️ Nx Cloud last updated this comment at |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #1229
Problem
With
anchorTo: 'end'and element scrolling, the trackedscrollOffsetwas written without clamping to the element's reachable range in two places:applyScrollAdjustment()— the eagerthis.scrollOffset += this.scrollAdjustmentswritesetOptions()edge-key re-anchor block —this.scrollOffset = anchorItem.start + anchorOffsetWhen items measure smaller than their estimates and the content is shorter than the viewport, the end-anchor compensation applies a negative delta. The DOM
scrollTopwrite is clamped to 0 by the browser, but the tracked offset keeps the negative value — and since an unscrollable element never fires a scroll event, nothing ever corrects it. For the lifetime of the instance:getDistanceFromEnd()reports a constant phantom distance andisAtEnd()stays false, so anything steeringscrollToEnd()toward convergence spins forever_flushIosDeferredIfReady()early-returns whilegetScrollOffset() < 0(the rubber-band guard), so on iOS WebKit deferred measurement corrections stay queued forever and items freeze at their estimated positionsFix
Clamp only the lower bound in both writes. Upper-bound overflow is deliberately left alone — it is transiently legitimate mid-prepend while the consumer's sizer catches up, but a negative element offset is invalid unconditionally.
Tests
Two regression tests reproducing the issue's minimal conditions (unscrollable element,
anchorTo: 'end', estimates larger than measured sizes). Both fail onmain(tracked offset lands at a stable-10, exactly as reported) and pass with the clamps.🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests