Virtualization supports Beginning|End|None anchor modes#66073
Open
ilonatommy wants to merge 6 commits intomainfrom
Open
Virtualization supports Beginning|End|None anchor modes#66073ilonatommy wants to merge 6 commits intomainfrom
Beginning|End|None anchor modes#66073ilonatommy wants to merge 6 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an opt-in anchoring API to Virtualize<TItem> so apps can control whether the viewport “pins” to the beginning and/or end of a virtualized list as items are added, enabling chat/log/feed-style UX patterns.
Changes:
- Introduces
VirtualizeAnchorMode(None|Beginning|End) and exposes it asVirtualize<TItem>.AnchorMode(default:Beginning). - Extends Virtualize JS interop to accept
anchorMode, gating convergence behavior and adding a None-mode prepend compensation path. - Adds a BasicTestApp test page plus new E2E coverage for anchor mode scenarios.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Components/Web/src/Virtualization/VirtualizeJsInterop.cs | Extends JS init interop to pass anchorMode (and root margin). |
| src/Components/Web/src/Virtualization/VirtualizeAnchorMode.cs | Adds new public [Flags] enum defining anchoring modes. |
| src/Components/Web/src/Virtualization/Virtualize.cs | Adds AnchorMode parameter and C#/render hooks for None-mode prepend compensation + bottom convergence suppression in None. |
| src/Components/Web/src/PublicAPI.Unshipped.txt | Declares the new public API surface. |
| src/Components/Web.JS/src/Virtualize.ts | Implements anchor-mode gated convergence and None-mode prepend compensation + suppression logic. |
| src/Components/test/testassets/BasicTestApp/VirtualizationAnchorMode.razor | Adds a manual test page for switching anchor mode and prepending/appending items. |
| src/Components/test/testassets/BasicTestApp/Index.razor | Adds navigation entry for the new test page. |
| src/Components/test/E2ETest/Tests/VirtualizationTest.cs | Adds E2E tests validating behavior for None/Beginning/End modes. |
This was referenced Apr 1, 2026
Open
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.
Summary
Adds a new
AnchorModeparameter to theVirtualize<TItem>component that controls how the viewport behaves at list edges when items are added dynamically.New API
Virtualize<TItem>.AnchorMode— default isBeginning(matches .NET 10 behavior at the top edge).Modes can be combined:
Beginning | Endpins both edges. CombiningNonewith other modes is supported but does not change the combined value -> sinceNone = 0the combinationNone | Beginningis just Beginning.Behavior matrix
Changes
C# (
Virtualize.cs,VirtualizeJsInterop.cs)AnchorModecomponent parameter with[Parameter]_pendingScrollToBottomgated on(AnchorMode & End) != 0instead of!= NoneOnAfterRenderAsync, pushes to JS viaSetAnchorModeAsyncdata-scroll-compensateattribute, JS adjustsscrollTopJS (
Virtualize.ts)anchorModeparameter flows intoinit(), gating convergence logic:onSpacerBeforeVisible): gated onanchorMode & 1(Beginning)onSpacerAfterVisible): gated onanchorMode & 2(End)setAnchorModeexport for dynamic updatesscrollEventTargetfix: usesscrollContainer ?? windowfor scroll unlock handler (fixes window-scrolling mode)scrollElement.scrollTop += spacerBefore.offsetHeight(was=, broke window-scrolling)Fixes #65742.