Fix Virtualize scroll jump caused by native overflow-anchor double compensation#67781
Draft
ilonatommy wants to merge 5 commits into
Draft
Fix Virtualize scroll jump caused by native overflow-anchor double compensation#67781ilonatommy wants to merge 5 commits into
ilonatommy wants to merge 5 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a Virtualize regression where incremental scrolling could “snap” toward the start/end when ItemSize differs from actual rendered item height, by avoiding double scroll-compensation between Virtualize’s reserved-height stabilization and the browser’s native overflow-anchor.
Changes:
- Toggle
overflow-anchoron the scroll element during scroll-driven spacer redistribution to prevent native anchoring from over-correcting. - Update the BasicTestApp virtualization test asset to produce a stronger item-size mismatch scenario.
- Add an E2E test + helper script to detect large per-step scroll jumps in an overflow container.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Components/Web.JS/src/Virtualize.ts | Adjusts native scroll-anchoring behavior during scroll-driven spacer redistribution to prevent over-compensation. |
| src/Components/test/testassets/BasicTestApp/VirtualizationComponent.razor | Tweaks the mismatch scenario (declared vs actual height) used by tests to reproduce the regression more deterministically. |
| src/Components/test/E2ETest/Tests/VirtualizationTest.cs | Adds an E2E regression test and JS helper to detect large jump deltas during incremental container scrolling. |
Member
Author
|
This PR has faulty regression tests, converting to WIP |
ilonatommy
marked this pull request as draft
July 15, 2026 09:49
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 #67729
A regression (introduced by #65951) where
Virtualizewould eventually converge to start/end of the list incremental scrolling, even when the scroll diff was small. It happened when the declaredItemSizediffers from the real rendered row height. It doesn't occur in the case when real items match the declared sizes.Background
The viewport stabilization PR reserved-height spacers that
Virtualizeresizes as it discovers the true item sizes (let's call it mechanism A). The browser's native CSSoverflow-anchoralso tries to keep the scroll position stable across those layout changes (mechanism B).The two mechanisms were by design supposed to not overlap. However, a case where the overlap happens was overlooked. That case is scroll-driven redistribution where the spacer's estimated height differs from the real rendered height. When both mechanisms are stacked, the scroll offset is over-corrected and snapping the viewport to the top/bottom happens.
Fix
Suppress native
overflow-anchorsynchronously during scroll-driven spacer redistribution (processIntersectionEntries), so the browser doesn't compensate on top of our spacer resize.Restore it (
overflowAnchor = '') synchronously on the first non-scroll render (refreshObservedElements), guarded against convergence states.This mirrors the synchronous convergence-anchor toggling already used by viewport stabilization PR that uses the mechanism A when mechanism B is not available/reliable.
Tests
incorrect-item-sixe-fixed.mp4