[DataGridPro] Fix lazy loading params for page with one row#21139
Merged
MBilalShafi merged 9 commits intomui:masterfrom Feb 6, 2026
Merged
[DataGridPro] Fix lazy loading params for page with one row#21139MBilalShafi merged 9 commits intomui:masterfrom
MBilalShafi merged 9 commits intomui:masterfrom
Conversation
|
Deploy preview: https://deploy-preview-21139--material-ui-x.netlify.app/ Bundle size report
|
- Move adjustRowParams from useGridDataSourceLazyLoader hook to lazyLoader/utils.ts - Make it a pure function with explicit pageSize and rowCount parameters - Fix edge case where rowCount of 0 would result in negative end index - Add unit tests for the utility function Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Use a more specific GridRowRenderContext type that only requires firstRowIndex and lastRowIndex, instead of the full GridRenderContext which also requires column indices that aren't used by the function. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove export from GridRowRenderContext and AdjustRowParamsOptions interfaces as they are only used internally. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When rowCount is -1 (infinite/unknown), the adjustRowParams function was incorrectly calculating maxEnd as Math.max(0, -2) = 0, which capped all requests at end=0. This fix treats rowCount=-1 the same as undefined, allowing infinite loading to fetch rows without capping. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
arminmeh
reviewed
Jan 30, 2026
Add test case for issue mui#21104 where rowCount % pageSize === 1 (e.g., rowCount=31 with pageSize=10) to verify the last page with a single row is correctly fetched. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Do you have a rough estimate when this will be merged & released? I need to decide whether to hack around this bug or if we can wait for the fix and tolerate it that long... |
Contributor
@maxhollmann, I will finish my review soon, and it should be merged soon and released next week. |
arminmeh
approved these changes
Feb 5, 2026
Contributor
|
Cherry-pick PRs will be created targeting branches: v8.x |
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
The lazy loader hook was miscalculating pagination parameters for single-row pages, causing them to remain unfetched. This PR extracts the core utility function to enable proper testing and reusability in follow-up improvements.
Problem
When a page contained only a single row, the lazy loading params calculation would incorrectly cap the row count at
-1, preventing the data from being fetched and leaving the loader in an infinite loading state.Solution
✨ Key Changes:
adjustRowParamsas a pure utility function for better testabilityImpact
Testing
adjustRowParamsutility functionFixes #21104