Skip to content

[DataGrid] Wait for rows before reacting on autosizeOnMount#22698

Open
MBilalShafi wants to merge 3 commits into
mui:masterfrom
MBilalShafi:codex/fix-22505-autosize
Open

[DataGrid] Wait for rows before reacting on autosizeOnMount#22698
MBilalShafi wants to merge 3 commits into
mui:masterfrom
MBilalShafi:codex/fix-22505-autosize

Conversation

@MBilalShafi

@MBilalShafi MBilalShafi commented Jun 5, 2026

Copy link
Copy Markdown
Member

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.

Fixes #22505

Closes #20551

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.
@MBilalShafi MBilalShafi added type: bug It doesn't behave as expected. scope: data grid Changes related to the data grid. feature: Column resize labels Jun 5, 2026
@code-infra-dashboard

code-infra-dashboard Bot commented Jun 5, 2026

Copy link
Copy Markdown

Deploy preview

https://deploy-preview-22698--material-ui-x.netlify.app/

Bundle size

Bundle Parsed size Gzip size
@mui/x-data-grid 🔺+480B(+0.12%) 🔺+136B(+0.11%)
@mui/x-data-grid-pro 🔺+480B(+0.09%) 🔺+148B(+0.10%)
@mui/x-data-grid-premium 🔺+480B(+0.07%) 🔺+135B(+0.07%)
@mui/x-charts 0B(0.00%) 0B(0.00%)
@mui/x-charts-pro 0B(0.00%) 0B(0.00%)
@mui/x-charts-premium 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers-pro 0B(0.00%) 0B(0.00%)
@mui/x-tree-view 0B(0.00%) 0B(0.00%)
@mui/x-tree-view-pro 0B(0.00%) 0B(0.00%)
@mui/x-license 0B(0.00%) 0B(0.00%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

@MBilalShafi MBilalShafi marked this pull request as ready for review June 5, 2026 16:35
@MBilalShafi MBilalShafi requested review from a team and Copilot June 5, 2026 16:35
@MBilalShafi MBilalShafi added needs cherry-pick The PR should be cherry-picked to master after merge. v8.x labels Jun 5, 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 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 by renderedRowsIntervalChange/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.

Comment thread packages/x-data-grid-pro/src/tests/columns.DataGridPro.test.tsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: Column resize needs cherry-pick The PR should be cherry-picked to master after merge. scope: data grid Changes related to the data grid. type: bug It doesn't behave as expected. v8.x

Projects

None yet

2 participants