Skip to content

Fix QuickGrid End-mode async-provider prepend viewport drift - #67938

Merged
ilonatommy merged 3 commits into
dotnet:mainfrom
ilonatommy:fix-quickgrid-end-anchoring
Jul 22, 2026
Merged

ilonatommy merged 3 commits into
dotnet:mainfrom
ilonatommy:fix-quickgrid-end-anchoring

Conversation

@ilonatommy

Copy link
Copy Markdown
Member

Follow-up to #67931 (AnchorMode.None) and #67935 (AnchorMode.Start), extending the same fix to AnchorMode.End. Contributes to #67865.

The problem

QuickGrid renders as a <table>, so Virtualize uses manual JS scroll compensation. On Blazor Server the anchor restore is an async round-trip, and during that latency two things went wrong in End mode (same failures already fixed for None/Start):

  1. Anchor captured mid-load: the top row sat in a placeholder gap, so the restore used the wrong offset.
  2. Premature scroll callback undid the shift: a stray spacer-before observer recomputed a smaller window and reverted the prepend (index jumped 90 -> 80).

The fix

Extend the two existing guards to End: hold _pendingAnchorRestore across the round-trip (Virtualize.cs) and skip the transient loading-gap snapshot (Virtualize.ts).

The key difference from Start: End needs no "not at top" gate. Start must converge to the new first item on a top prepend (so #67935 gates it with _deferPrependAnchorClear/!convergingToTop). End anchors the current row at every position and never anchors an append (ShouldAnchorForAppend excludes End), so its deferral is unconditional. Uses the bitmask form to match convention and cover Start | End.

New QuickGrid AnchorMode test coverage summary, updated
Op · Position · Source None Start End
⬆️ · Exact top · Items V ✅ · QG 🆕 ✅ 0/5 V ✅ · QG 🆕 ✅ 0/5 V ✅ · QG 🆕 ✅ 0/5
⬆️ · Exact top · Prov V ✅ · QG ✅ 0/5 (fixed) V ✅ · QG 🆕 ✅ 0/5 V ✅ · QG ✅ 0/5 (fixed End)
⬆️ · Exact top · Prov+delay V n/a · QG ✅ 0/5 (fixed) V n/a · QG 🆕 ✅ 0/5 V n/a · QG ✅ 0/5 (fixed End)
⬆️ · Near-top ~200px · Items V ✅ · QG 🆕 ✅ 0/5 V ✅ · QG 🆕 ✅ 0/5 V ✅ · QG 🆕 ✅ 0/5
⬆️ · Near-top ~200px · Prov V ✅ · QG ✅ 0/5 (fixed) V ✅ · QG ✅ 0/5 (fixed Start) V ✅ · QG ✅ 0/5 (fixed End)
⬆️ · Near-top ~200px · Prov+delay V n/a · QG ✅ 0/5 (fixed) V n/a · QG ✅ 0/5 (fixed Start) V n/a · QG ✅ 0/5 (fixed End)
⬆️ · Mid-list · Items V ✅ · QG 🆕 ✅ 0/5 V ✅ · QG 🆕 ✅ 0/5 V ✅ · QG 🆕 ✅ 0/5
⬆️ · Mid-list · Prov V ✅ · QG ✅ 0/5 (fixed) V ✅ · QG ✅ 0/5 (fixed Start) V ✅ · QG ✅ 0/5 (fixed End)
⬆️ · Mid-list · Prov+delay V ✅ · QG ✅ 0/5 (fixed, None_AsyncProvider [Fact]) — —
⬆️ · Bottom · Items V ✅ · QG 🆕 ✅ 0/5 V ✅ · QG 🆕 ✅ 0/5 V ✅ · QG 🆕 ✅ 0/5
⬆️ · Bottom · Prov V ✅ · QG ✅ 0/5 (fixed) V ✅ · QG ✅ 0/5 (fixed Start) V ✅ · QG ✅ 0/5 (fixed End)
⬆️ · After leaving top · Items — V ✅ · QG 🆕 ✅ 0/5 —
⬆️ · After leaving top · Prov — V ✅ · QG 🆕 ✅ 0/5 —
⬇️ · Near-top · Items V ✅ · QG 🆕 ✅ 0/5 V ✅ · QG 🆕 ✅ 0/5 V ✅ · QG 🆕 ✅ 0/5
⬇️ · Near-top · Prov V ✅ · QG 🆕 ✅ 0/5 V ✅ · QG 🆕 ✅ 0/5 V ✅ · QG 🆕 ✅ 0/5
⬇️ · Top · Items V ✅ · QG 🆕 ✅ 0/5 V ✅ · QG 🆕 ✅ 0/5 V ✅ · QG 🆕 ✅ 0/5
⬇️ · Top · Prov V ✅ · QG 🆕 ✅ 0/5 V ✅ · QG 🆕 ✅ 0/5 V ✅ · QG 🆕 ❌ 1/6
⬇️ · Mid-list · Items V ✅ · QG 🆕 ✅ 0/5 V ✅ · QG 🆕 ✅ 0/5 V ✅ · QG 🆕 ✅ 0/5
⬇️ · Mid-list · Prov V ✅ · QG 🆕 ✅ 0/5 V ✅ · QG 🆕 ✅ 0/5 V ✅ · QG 🆕 ✅ 0/5
⬇️ · Bottom · Items V ✅ · QG 🆕 ✅ 0/5 V ✅ · QG 🆕 ✅ 0/5 V ✅ · QG 🆕 ✅ 0/5
⬇️ · Bottom · Prov V ✅ · QG 🆕 ✅ 0/5 V ✅ · QG 🆕 ✅ 0/5 V ✅ · QG 🆕 ✅ 0/5
⬇️ · After leaving bottom · Items — — V ✅ · QG 🆕 ✅ 0/5
⬇️ · After leaving bottom · Prov — — V ✅ · QG 🆕 ✅ 0/5
⬇️ LARGE (100) · Bottom · Items — V ✅ · QG 🆕 ❌ WASM V ✅ · QG 🆕 ✅ 0/5
⬇️ LARGE (100) · Bottom · Prov — V ✅ · QG 🆕 ✅ 0/5 V ✅ · QG 🆕 ✅ 0/5
⌨️ Home key → top · Items/Prov — · QG 🆕 ✅ 0/5 — · QG 🆕 ✅ 0/5 — · QG 🆕 ✅ 0/5
⌨️ End key → bottom · Items/Prov — · QG 🆕 ✅ 0/5 — · QG 🆕 ✅ 0/5 — · QG 🆕 ❌ 1/6 (CI/Mono)

@ilonatommy ilonatommy added this to the 11.0-preview7 milestone Jul 21, 2026
@ilonatommy ilonatommy self-assigned this Jul 21, 2026
Copilot AI review requested due to automatic review settings July 21, 2026 15:04
@ilonatommy ilonatommy added the area-blazor Includes: Blazor, Razor Components label Jul 21, 2026
@ilonatommy
ilonatommy requested a review from a team as a code owner July 21, 2026 15:04
@ilonatommy ilonatommy added feature-blazor-virtualization This issue is related to the Blazor Virtualize component feature-blazor-quickgrid labels Jul 21, 2026
@ilonatommy
ilonatommy temporarily deployed to copilot-pat-pool July 21, 2026 15:04 — with GitHub Actions Inactive
@ilonatommy
ilonatommy temporarily deployed to copilot-pat-pool July 21, 2026 15:04 — with GitHub Actions Inactive

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.

Pull request overview

Extends the existing Virtualize/QuickGrid manual scroll-anchoring safeguards to AnchorMode.End to prevent viewport drift during async-provider prepends (particularly for table-based QuickGrid on Blazor Server).

Changes:

  • In Virtualize.cs, defers clearing _pendingAnchorRestore for End mode so spacer callbacks can’t revert the prepend during the async restore round-trip.
  • In Virtualize.ts, skips capturing transient “loading-gap” anchor snapshots for End mode (same guard previously applied to None/Start).
  • In VirtualizationTest.cs, re-enables previously-disabled QuickGrid End + async provider test variants.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/Components/Web/src/Virtualization/Virtualize.cs Extends anchor-restore deferral logic to cover End mode during async restore.
src/Components/Web.JS/src/Virtualize.ts Avoids replacing stable anchor snapshots with transient “loading gap” snapshots in End mode.
src/Components/test/E2ETest/Tests/VirtualizationTest.cs Re-enables End-mode async-provider E2E coverage now that the drift fix is in place.

@ilonatommy
ilonatommy enabled auto-merge (squash) July 22, 2026 09:50
@ilonatommy
ilonatommy merged commit 31b471d into dotnet:main Jul 22, 2026
26 checks passed
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-quickgrid 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.

3 participants