Repository navigation
MudDataGrid, MudTable: Don't stay on empty page after ServerData load - #13949
Merged
danielchalmers merged 1 commit intoOct 12, 2026
Merged
danielchalmers merged 1 commit into
danielchalmers merged 1 commit into
Conversation
…t with ServerData (MudBlazor#13948) With ServerData the page was reset to 0 only when CurrentPage * RowsPerPage was greater than TotalItems. When the total was exactly equal to the offset of the current page, the grid or table stayed on an empty page (pager showed e.g. 31-30 of 30). The comparison is now >= in MudDataGrid.InvokeServerLoadFunc and MudTable.InvokeServerLoadFunc; both setters are no-ops for an unchanged page, so an empty first page does not trigger an extra load. Tests: DataGridTests.ServerDataResetsToFirstPageWhenCurrentPageOverflows, DataGridTests.ServerDataResetsToFirstPageWhenTotalItemsEqualsPageOffset, TableTests.ServerDataResetsToFirstPageWhenTotalItemsEqualsPageOffset and the test component DataGridServerDataPageResetTest. Fixes MudBlazor#13948
I'm an AI assistant — If I missed something or made a mistake, please let me know in a reply! |
This comment was marked as low quality.
This comment was marked as low quality.
Member
|
Please post before and after videos that were recorded yourself from your own local run. |
Contributor
Author
|
Here are before and after videos recorded from my own local run of Before (this branch with the fix reverted): both 2026-10-07.17-27-58.mp4After (this branch): both grids move to page 1 and the pager reads 2026-10-07.17-29-35.mp4 |
danielchalmers
approved these changes
Oct 12, 2026
Member
|
Thanks! |
This was referenced Oct 13, 2026
This was referenced Oct 30, 2026
This was referenced Nov 16, 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.
Fixes #13948
What: With
ServerData, bothMudDataGridandMudTableresetCurrentPageto 0 after a load when the current page lies beyond the returnedTotalItems. The check used>, so a result whose total is exactly equal to the offset of the current page (for example 30 items while on page 4 with 10 rows per page) was treated as still valid, and the grid stayed on an empty page with the pager showing31-30 of 30. The comparison is now>=inMudDataGrid.InvokeServerLoadFuncandMudTable.InvokeServerLoadFunc.Why it is safe: when the current page is already 0 the condition can only trigger
CurrentPage = 0/SetCurrentPage(0), and both are no-ops for an unchanged value, so an empty result on the first page does not cause an extra load.Tests:
DataGridTests.ServerDataResetsToFirstPageWhenCurrentPageOverflows(regression cover for the existing reset path, there was none for the grid)DataGridTests.ServerDataResetsToFirstPageWhenTotalItemsEqualsPageOffset(the boundary; fails without the fix:Expected dataGrid.CurrentPage to be 0, but found 2)TableTests.ServerDataResetsToFirstPageWhenTotalItemsEqualsPageOffset(the boundary; fails without the fix:Expected table.CurrentPage to be 0, but found 2)DataGridServerDataPageResetTest.razor, modelled on the existingTableCurrentPageServerDataReapplyTest.razorVerified locally with the filtered run
--filter "FullyQualifiedName~Components.DataGridTests|FullyQualifiedName~Components.TableTests".No public API change, no breaking behavior.
AI assistance: the fix, the tests and this description were drafted with an AI coding assistant (Claude) and reviewed and run by me.
Before/After:
Before: on page 4 with 10 rows per page, a filter that leaves exactly 30 items shows an empty grid with the pager
31-30 of 30.After: the grid moves to page 1 and shows
1-10 of 30.Before

After

Checklist: