Skip to content

Conversation

@dariatiurina
Copy link
Contributor

Fix multiple requests for ItemsProvider when changing the TotalItemCount

Description

This pull request improves the QuickGrid component by fixing how pagination state is tracked to prevent unnecessary data refreshes, and adds new end-to-end tests and a test component to verify correct ItemsProvider call behavior when filtering. The main focus is on ensuring that applying filters via pagination reset or explicit data refresh does not trigger extra data loads.

Changes:

  • Moved the assignment of _lastRefreshedPaginationStateHash in QuickGrid.razor.cs to after the data load completes, ensuring the hash accurately reflects the refreshed state and preventing unnecessary refreshes.
  • Added new end-to-end tests in QuickGridTest.cs to verify that filtering with either pagination reset or explicit refresh only results in a single additional ItemsProvider call, preventing redundant refreshes.
  • Introduced a new test component, QuickGridFilterComponent.razor, to support these tests by simulating filtering and tracking ItemsProvider calls.

Fixes #62605

@dariatiurina dariatiurina self-assigned this Dec 5, 2025
@github-actions github-actions bot added the area-blazor Includes: Blazor, Razor Components label Dec 5, 2025
@dariatiurina dariatiurina marked this pull request as ready for review December 5, 2025 10:29
@dariatiurina dariatiurina requested a review from a team as a code owner December 5, 2025 10:29
Copilot AI review requested due to automatic review settings December 5, 2025 10:29
Copilot finished reviewing on behalf of dariatiurina December 5, 2025 10:32
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes a pagination state tracking issue in the QuickGrid component that was causing unnecessary data refreshes when filters changed the TotalItemCount. The fix ensures that the pagination state hash is updated only after data loads complete successfully, preventing premature state tracking that could trigger redundant refresh cycles.

Key changes:

  • Moves _lastRefreshedPaginationStateHash assignment to after data load completion in the non-virtualized path
  • Adds comprehensive E2E tests to verify single ItemsProvider calls when filtering via pagination reset or explicit refresh
  • Introduces a new test component to simulate and verify filtering behavior

Reviewed changes

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

File Description
src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/QuickGrid.razor.cs Relocates pagination state hash assignment to occur after successful data load instead of before, fixing double-refresh issue
src/Components/test/testassets/BasicTestApp/QuickGridTest/QuickGridFilterComponent.razor New test component simulating filter application with call count tracking to validate the fix
src/Components/test/E2ETest/Tests/QuickGridTest.cs Adds two new test cases verifying single ItemsProvider call for both pagination reset and explicit refresh scenarios
src/Components/test/testassets/BasicTestApp/Index.razor Registers the new test component in the test app navigation menu

@ilonatommy ilonatommy added this to the 11.0-preview1 milestone Dec 5, 2025
@dariatiurina dariatiurina enabled auto-merge (squash) December 5, 2025 15:33
@dariatiurina dariatiurina merged commit 7f1e7a5 into dotnet:main Dec 5, 2025
30 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

QuickGrid problem with _lastRefreshedPaginationStateHash = Pagination?.GetHashCode();

2 participants