Skip to content

[release/11.0-preview7] Virtualize tests with ItemProvider should always contain a delay - #68036

Merged
akoeplinger merged 1 commit into
dotnet:release/11.0-preview7from
ilonatommy:backport/pr-67959-to-release/11.0-preview7
Jul 27, 2026
Merged

akoeplinger merged 1 commit into
dotnet:release/11.0-preview7from
ilonatommy:backport/pr-67959-to-release/11.0-preview7

Conversation

@ilonatommy

@ilonatommy ilonatommy commented Jul 27, 2026 •

Copy link
Copy Markdown
Member

Backport of #67959 to release/11.0-preview7

Description

Real-life ItemsProvider implementations always come with some delay, so Virtualize and QuickGrid virtualization tests that use a provider which merely await Task.Yield() do not reflect real usage. This change makes all AnchorMode / ScrollToItem / InitialItemIndex tests added in net11 exercise the delayed-provider case consistently, and fixes the three product bugs that the delayed coverage revealed:

  1. AnchorMode_VariableHeight_EndKeyFromTop_JumpsToBottom - the re-pinning mechanism that handles a placeholder→real-item transition growing scrollHeight was enabled only for End anchor mode. It now applies to all modes, so an End-key jump lands and stays at the bottom once real (larger) items load.
  2. AnchorMode_End_HomeKeyFromBottom_JumpsToTop - in End mode with a delayed provider, bottomTracking.reached was sticky-true and never reset, so a Home jump was pulled back to the bottom by auto-follow. Auto-follow is now disabled for all modes on a Home jump.
  3. AnchorMode_End_PrependAtTop_ViewportStaysStable - after Fix Virtualize scroll jump from native/JS anchoring double-compensation #67934 landed, native scroll anchoring is (by spec) suppressed at scrollTop = 0, so a prepend at the very top was not compensated and left the viewport blank. Manual anchoring is now applied for element scrollers at the top of scroll.

Customer Impact

Blazor Virtualize and QuickGrid mis-behave with real (delayed) async item providers in scenarios that were newly enabled in net11: an End-anchored Home-key jump snaps back to the bottom, a variable-height End-key jump bounces back up once real items load, and a prepend at the top of the list leaves the viewport blank. These are common patterns for data-bound grids backed by network calls. The fixes make anchoring behave correctly for delayed providers.

Regression?

  • Yes
  • No

All affected code was introduced during the net11 preview cycle and has not shipped in a stable release. Bug 3 is an internal regression within net11 introduced by #67934 (also preview-only); it is corrected here.

Risk

  • High
  • Medium
  • Low

The change is dominated by test additions (7 of 9 files). The single framework file (Virtualize.ts, ~40 lines) narrowly scopes the anchoring re-pin / manual-anchor logic and is exercised by the expanded E2E AnchorMode suite, which passes.

Verification

  • Manual (required)
  • Automated

The full ServerVirtualizationTest.AnchorMode E2E suite and the QuickGrid/Virtualize
delayed-provider tests pass locally.

Packaging changes reviewed?

  • Yes
  • No
  • N/A

…otnet#67959)

* All ItemProvider tests should use delay to reproduce real life scenario.

* Make failures of `AnchorMode_VariableHeight_EndKeyFromTop_JumpsToBottom deterministic - wait for the placeholders to transform to real items, only then scroll down and check if the initial landing was at the bottom or bumped up.

* Fix Virtualize End-key not converging to true bottom in None/Start anchor modes.

* Fix Virtualize End-mode Home key not converging to top after async re-render

* Fix race in AnchorMode_WindowScroll_None_LargeAppendAtBottom_DoesNotFollowToBottom

* Native anchoring has one blind spot: topmost scroll position (https://www.w3.org/TR/css-scroll-anchoring-1/). We have to use manual anchoring then.

* When we don't have container (document/window scroll scenarios) then native scroll works fine.
@ilonatommy
ilonatommy marked this pull request as ready for review July 27, 2026 11:30
@ilonatommy
ilonatommy requested a review from a team as a code owner July 27, 2026 11:30
Copilot AI review requested due to automatic review settings July 27, 2026 11:30
@ilonatommy ilonatommy self-assigned this Jul 27, 2026
@ilonatommy ilonatommy added area-blazor Includes: Blazor, Razor Components feature-blazor-virtualization This issue is related to the Blazor Virtualize component labels Jul 27, 2026
@ilonatommy ilonatommy added this to the 11.0-preview7 milestone Jul 27, 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.

Pull request overview

This backport aligns Virtualize/QuickGrid virtualization coverage with real-world async ItemsProvider behavior by ensuring tests consistently exercise providers with a real delay, and it includes a small Virtualize.ts anchoring update to address issues exposed by that delayed-provider coverage.

Changes:

  • Updated Virtualize.ts scroll anchoring/follow logic to correctly handle delayed provider placeholder→real-item transitions (including Home/End key behavior and top-of-scroll manual anchoring for element scrollers).
  • Updated E2E tests and test assets to consistently enable provider delay when exercising ItemsProvider scenarios, including new coverage for the reported delayed-provider bugs.
  • Added/extended test UI toggles and query parameters to enable provider delay in repro/test components.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Components/Web.JS/src/Virtualize.ts Adjusts bottom-follow state handling and anchor snapshot behavior to fix delayed-provider anchoring edge cases.
src/Components/test/testassets/Components.TestServer/RazorComponents/Pages/Virtualization/VirtualizeAppendRepro.razor Adds a delay query parameter to control provider delay in the server rendering repro page.
src/Components/test/testassets/BasicTestApp/VirtualizationAnchorModeWindowScroll.razor Adds a UI toggle to simulate delayed ItemsProvider behavior for window-scroll anchor mode coverage.
src/Components/test/testassets/BasicTestApp/VirtualizationAnchorMode.razor Updates delay status messaging to match the new test expectations.
src/Components/test/testassets/BasicTestApp/QuickGridTest/QuickGridVariableHeightComponent.razor Adds a provider-delay toggle and status text to exercise delayed-provider QuickGrid variable-height scenarios.
src/Components/test/testassets/BasicTestApp/QuickGridTest/QuickGridScrollComponent.razor Updates delay status messaging for consistency with revised E2E expectations.
src/Components/test/testassets/BasicTestApp/QuickGridTest/QuickGridAnchorModeComponent.razor Updates UI/status text to clearly indicate QuickGrid provider delay state (consumed by tests).
src/Components/test/E2ETest/Tests/VirtualizationTest.cs Enables provider delay by default for ItemsProvider-based virtualization test cases and adds new delayed-provider regression tests.
src/Components/test/E2ETest/ServerRenderingTests/VirtualizationRenderModesTest.cs Navigates to the server-rendered repro with a non-zero delay to ensure coverage matches real provider latency.

@ilonatommy ilonatommy added the tell-mode Indicates a PR which is being merged during tell-mode label Jul 27, 2026
@akoeplinger

Copy link
Copy Markdown
Member

/ba-g build analysis is stuck but all AzDO builds are green

@akoeplinger
akoeplinger merged commit 89467cb into dotnet:release/11.0-preview7 Jul 27, 2026
43 of 46 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-virtualization This issue is related to the Blazor Virtualize component tell-mode Indicates a PR which is being merged during tell-mode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants