[DataGrid] Wait for rows before reacting on autosizeOnMount#22698
Open
MBilalShafi wants to merge 3 commits into
Open
[DataGrid] Wait for rows before reacting on autosizeOnMount#22698MBilalShafi wants to merge 3 commits into
autosizeOnMount#22698MBilalShafi wants to merge 3 commits into
Conversation
Delay autosizeOnMount until the initial render context is ready and committed, so fitting rows are measured before column widths are extracted. Add a browser regression test covering a wide value in the last rendered row.
Deploy previewhttps://deploy-preview-22698--material-ui-x.netlify.app/ Bundle size
Check out the code infra dashboard for more information about this PR. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts the DataGrid autosizeOnMount behavior so it runs only after the initial render context is ready/committed, ensuring row cells are actually measurable before column widths are extracted (fixing the “last row wide value not considered” bug from #22505).
Changes:
- Add a render-context readiness gate for
autosizeOnMount, driven byrenderedRowsIntervalChange/stateChange, and schedule autosize on the next animation frame once ready. - Add a browser regression test that reproduces the issue by delaying the final row’s rendered cell content, then asserts the wide value is fully visible after autosizing.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/x-data-grid/src/hooks/features/columnResize/useGridColumnResize.tsx | Delays autosizeOnMount until dimensions + row render context indicate rows are committed/ready for measurement. |
| packages/x-data-grid-pro/src/tests/columns.DataGridPro.test.tsx | Adds a regression test for autosize measuring the last rendered row’s wide value. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Delay
autosizeOnMountuntil the initial render context is ready and committed, so fitting rows are measured before column widths are extracted.Add a browser regression test covering a wide value in the last rendered row.
Fixes #22505
Closes #20551