Expose InitialItemIndex parameter and ScrollToItemAsync method on QuickGrid - #67914
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR exposes InitialItemIndex and ScrollToItemAsync as public, non-experimental APIs on QuickGrid<TGridItem> by forwarding to the underlying Virtualize component, and adds new BasicTestApp + E2E coverage to validate the behavior end-to-end.
Changes:
- Added
QuickGrid<TGridItem>.InitialItemIndexparameter andQuickGrid<TGridItem>.ScrollToItemAsync(...)method, forwarding toVirtualize. - Forwarded
InitialItemIndexfromQuickGridto the inner<Virtualize>instance. - Added a new BasicTestApp component and new E2E tests covering scrolling/initial-index behaviors (including variable height, provider delay, rapid calls, and cancellation).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Components/test/testassets/BasicTestApp/QuickGridTest/QuickGridScrollComponent.razor | New test asset component exercising QuickGrid’s scroll APIs in a scrollable container. |
| src/Components/test/testassets/BasicTestApp/Index.razor | Adds the new QuickGrid scroll test component to the test asset menu. |
| src/Components/test/E2ETest/Tests/VirtualizationTest.cs | Adds E2E coverage for QuickGrid scroll-to-item and initial-index scenarios. |
| src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/QuickGrid.razor.cs | Adds the new public parameter and method (and validation) to QuickGrid. |
| src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/QuickGrid.razor | Forwards InitialItemIndex into the inner Virtualize component. |
| src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/PublicAPI.Unshipped.txt | Declares the newly added public API surface for API review tooling. |
ScrollToItem/InitialItemIndex on QuickGrid (a table) uses the manual compensation path. When an async ItemsProvider renders placeholders first, C# invokes alignToItemAt right after committing the render, while the MutationObserver that applies the spacer reserved-height styles is still pending. measureLocalChildOffset then reads stale (near-zero) spacer heights, so the target row measures near the top and the scroll delta is far too small (landed ~196px with a 10844px spacer, undershooting the target by ~3 rows). Flush the pending style mutations before measuring so the spacer heights, and therefore the target row offset, reflect the committed window. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d5314ec1-7255-4744-bb91-0225d535097f
…_AppendKeepsViewportStable.
dariatiurina
approved these changes
Jul 21, 2026
dariatiurina
approved these changes
Jul 21, 2026
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 two public, non-experimental APIs to
QuickGrid<TGridItem>that forward to its innerVirtualizecomponent:InitialItemIndexparameter - scrolls to the given row on first interactive render (clamped, applied once).ScrollToItemAsync(int itemIndex, CancellationToken)method - programmatically scrolls to a row, aligning it to the top. Last call wins; throwsInvalidOperationExceptionwhenVirtualizeis disabled or the grid isn't rendered yet.These mirror the existing
Virtualize.InitialItemIndex/Virtualize.ScrollToItemAsyncAPIs from #66328.API surface
Usage example