Skip to content

Expose experimental AnchorMode and ItemComparer on QuickGrid#67783

Draft
ilonatommy wants to merge 2 commits into
mainfrom
quickgrid-virtualize-intrinsic-tests
Draft

Expose experimental AnchorMode and ItemComparer on QuickGrid#67783
ilonatommy wants to merge 2 commits into
mainfrom
quickgrid-virtualize-intrinsic-tests

Conversation

@ilonatommy

@ilonatommy ilonatommy commented Jul 14, 2026

Copy link
Copy Markdown
Member

Adds two experimental parameters to QuickGrid<TGridItem> that let virtualized grids control viewport anchoring when data changes at the edges of the list:

  • AnchorMode (VirtualizeAnchorMode, default Start) - controls how the viewport behaves when new items arrive during virtualization (mirrors the existing Virtualize.AnchorMode).
  • ItemComparer (IEqualityComparer<TGridItem>?) - useful for reference types, lets the grid detect whether items were prepended or appended between data loads. Without it, anchoring across data changes might not work properly.

Both are marked [Experimental("ASP0030")], so consumers must explicitly opt in.

Virtualize already supports edge anchoring via AnchorMode/ItemComparer, but QuickGrid (which wraps Virtualize internally) only exposed the default Start behavior and provided no way to enable anchoring for ItemsProvider-backed grids. This closes that gap for scenarios like chat/log tails and infinite-scroll grids.

Virtualize changes

Pure Virtualize does a single render after the mutation (no extra StateHasChanged that is in QuickGrid and its RefreshDataAync deliberately avoids re-rendering). That extra render/observer-refresh pass is what generated additional spacer callbacks in the narrow window between render and restore. That's why the issue started manifesting only in QuickGrid tests, not in pure Virtualize.

A stale IntersectionObserver spacer callback landing between the shifted render and the anchor restore clobbered the JS anchor snapshot (dropping the scrollTop compensation) and recomputed the .NET window from pre-shift geometry,
causing QuickGrid prepend viewport jumps under an async ItemsProvider.

Fixed:

  • JS: skip the IO-callback snapshot refresh when scrollTop is unchanged.
  • C#: clear _pendingAnchorRestore only after RestoreAnchorAsync round-trips so in-flight stale spacer callbacks are ignored.

@ilonatommy ilonatommy self-assigned this Jul 14, 2026
@ilonatommy ilonatommy added area-blazor Includes: Blazor, Razor Components feature-blazor-virtualization This issue is related to the Blazor Virtualize component feature-blazor-quickgrid labels Jul 14, 2026
@ilonatommy ilonatommy force-pushed the quickgrid-virtualize-intrinsic-tests branch from 9b5a462 to 9904dd0 Compare July 14, 2026 17:25
@ilonatommy ilonatommy added this to the 11.0-preview7 milestone Jul 15, 2026
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.

1 participant