Skip to content

Fix Virtualize jumping away rom the bottom - #69926

Merged
ilonatommy merged 4 commits into
dotnet:mainfrom
ilonatommy:virtualize-end-anchor-rollback
Oct 23, 2026
Merged

ilonatommy merged 4 commits into
dotnet:mainfrom
ilonatommy:virtualize-end-anchor-rollback

Conversation

@ilonatommy

@ilonatommy ilonatommy commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Keep the end scroll when older log history is loaded.

Description

With end anchoring, Virtualize can scroll to the bottom and then jump back to an old item. An old scroll correction runs after the bottom scroll and undoes it.

Clear that correction when scrolling to the bottom. Add a browser test that loads older log history and checks that the bottom scroll is not undone.

To visualize the problem, the before and after behavior are same as in microsoft/aspire#21055.

Details Before (append clicked 3x, each of them look like a double append due to the mid-state):
aspire-issue.mp4

After:

after-fix.mp4

After fixing the original report, some appends were producing blank space on pinning, intermittently. It happens because Virtualize ignores requests to fill the viewport while restoring the scroll position to avoid responding to spacer notifications during the process. With specific timing, that might leave blank viewport. That timing depends when "empty space is visible" notification from the spacer observer reaches .net - if it happens when _pendingAnchorRestore is still true then the bug happens.
The fix saves the info about FillViewport being ignored. If any like this happened, we ask JS to refresh observation to make sure if no new FillViewport callback wouldn't be issued.

Details
aspire-blank-tail-demo.mp4

Fixes #69823

@ilonatommy ilonatommy self-assigned this Oct 19, 2026
@github-actions github-actions Bot added the area-blazor Includes: Blazor, Razor Components label Oct 19, 2026
…res the scroll position. Check again after restoration so the last items are loaded instead of leaving blank space at the bottom.
@ilonatommy
ilonatommy marked this pull request as ready for review October 20, 2026 10:57
@ilonatommy
ilonatommy requested a review from a team as a code owner October 20, 2026 10:57
@ilonatommy
ilonatommy requested review from dariatiurina and a balanced review from Copilot October 20, 2026 10:57
@ilonatommy ilonatommy added the feature-blazor-virtualization This issue is related to the Blazor Virtualize component label Oct 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Timing-sensitive observer and interop behavior still needs real-browser regression verification.

No open issues 🎉

What changed in this PR

Fixes Virtualize end anchoring so loading older history does not undo bottom scrolling, and retries viewport filling suppressed during anchor restoration.

Changes:

  • Clear stale scroll corrections after pinning to the bottom.
  • Refresh spacer observation when viewport-fill requests were deferred.
  • Add a browser regression scenario for sorted history loading.
File Description
src/​Components/​Web/​src/​Virtualization/​VirtualizeJsInterop.cs Pass the viewport-refresh flag to JavaScript.
src/​Components/​Web/​src/​Virtualization/​Virtualize.cs Track deferred viewport-fill requests.
src/​Components/​Web.JS/​src/​Virtualize.ts Reset stale corrections and refresh spacer observation.
src/​Components/​test/​testassets/​BasicTestApp/​VirtualizationEndAnchorHistory.razor Add a sorted-history test scenario.
src/​Components/​test/​testassets/​BasicTestApp/​Index.razor Register the new scenario.
src/​Components/​test/​E2ETest/​Tests/​VirtualizationTest.cs Detect bottom-pin rollback in browser coverage.

Review effort: Balanced

@dariatiurina dariatiurina left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, the only question is test. It's a bit hard to read

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: aff37fd2-5a5e-43e4-a438-446e4254957b
@ilonatommy
ilonatommy enabled auto-merge (squash) October 21, 2026 16:30
@ilonatommy
ilonatommy disabled auto-merge October 23, 2026 16:57
@ilonatommy
ilonatommy merged commit fc68a1d into dotnet:main Oct 23, 2026
32 checks passed
@ilonatommy

Copy link
Copy Markdown
Member Author

/backport to release/11.0

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/11.0 (link to workflow run)

@github-actions

Copy link
Copy Markdown
Contributor

✅ No documentation PR was created.

Confidence that documentation is needed: 5%

No docs needed: internal bug fix to Virtualize scroll anchoring with E2E tests; no signals detected.

Documentation surfaces considered

  • Conceptual article: Not required — Bug fix restoring expected Virtualize end-anchor scroll behavior; no public API or configuration change.
  • Migration guidance: Not required — No action needed when upgrading.
  • Breaking change: Not required — No compatibility impact; fixes scroll jumping and blank space.

wtgodbe pushed a commit that referenced this pull request Nov 3, 2026
* Reproduce automatic loading of older, timestamp-sorted provider history and assert that stale anchor correction cannot undo the bottom pin.

* Fix stale anchor correction undoing Virtualize end pin.

* A request to load visible items can be ignored while Virtualize restores the scroll position. Check again after  restoration so the last items are loaded instead of leaving blank space at the bottom.

* Simplify end-anchor history regression test




---------

Co-authored-by: Ilona Tomkowicz <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: aff37fd2-5a5e-43e4-a438-446e4254957b
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 4, 2026

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — b612c4e3 Deployed Oct 23, 2026 by ilonatommy via conclusion #96
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-blazor Includes: Blazor, Razor Components feature-blazor-virtualization This issue is related to the Blazor Virtualize component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Virtualize AnchorMode.End end scroll is undone by stale spacer correction

3 participants