Repository navigation
[data grid] Fix the height prop overflowing a narrow flex row parent - #23745
Merged
LukasTy merged 4 commits intoOct 2, 2026
Merged
Conversation
With the `height` prop, the root used `flex: 1 0 auto`. In a flex row parent, flex-shrink: 0 keeps the root at its content width, so the grid overflows a parent that is narrower than its columns. The root now uses `flex: 1`, and `minHeight` with `maxHeight` hold the height instead. This also fixes the flaky HeightGrid screenshot. The grid overflowed the 500px centered regression box and sat at a half pixel (x = -100.5). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Deploy previewBundle size
Check out the code infra dashboard for more information about this PR. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LukasTy
requested review from
JCQuintas and
michelengelen
and
a balanced review from Copilot
October 2, 2026 13:27
Member
Author
|
@JCQuintas, @michelengelen could you check if this is a potential regression that I keep postponing the release for? |
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The flex sizing and print-export changes are consistent and covered by targeted browser regression tests.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes Data Grid overflow in narrow flex-row containers while preserving fixed-height behavior.
Changes:
- Restores shrinkable root flex behavior and constrains prop-driven height with
minHeight/maxHeight. - Removes height constraints during print export.
- Adds layout and print regression tests and clarifies height documentation.
| File | Description |
|---|---|
packages/x-data-grid/src/tests/layout.DataGrid.test.tsx |
Tests flex sizing and height overrides. |
packages/x-data-grid/src/models/props/DataGridProps.ts |
Clarifies the height API contract. |
packages/x-data-grid/src/hooks/features/export/useGridPrintExport.tsx |
Resets height constraints for printing. |
packages/x-data-grid/src/DataGrid/DataGrid.tsx |
Updates generated prop documentation. |
packages/x-data-grid/src/components/containers/GridRootStyles.ts |
Fixes flex-row overflow while pinning height. |
packages/x-data-grid-pro/src/tests/printExport.DataGrid.test.tsx |
Tests print layout across height constraints. |
packages/x-data-grid-pro/src/DataGridPro/DataGridPro.tsx |
Updates Pro prop documentation. |
packages/x-data-grid-premium/src/DataGridPremium/DataGridPremium.tsx |
Updates Premium prop documentation. |
docs/translations/api-docs/data-grid/data-grid/data-grid.json |
Updates Data Grid API documentation. |
docs/translations/api-docs/data-grid/data-grid-pro/data-grid-pro.json |
Updates Pro API documentation. |
docs/translations/api-docs/data-grid/data-grid-premium/data-grid-premium.json |
Updates Premium API documentation. |
docs/data/data-grid/layout/layout.md |
Documents supported height values and overrides. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
JCQuintas
approved these changes
Oct 2, 2026
JCQuintas
left a comment
Member
There was a problem hiding this comment.
Nice, seems to be working
https://stackblitz.com/edit/pztmqw9c?file=src%2Fmain.jsx
Thanks for the fix
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
heightprop ([DataGrid] Addheightprop for sizing without a wrapper #23628), the root usesflex: 1 0 auto. In a flex row parent,flex-shrink: 0keeps the root at its content width, so the grid overflows a parent that is narrower than its columns.flex: 1again. The prop setsminHeightandmaxHeight, which hold the height in a flex column parent. The flex column tests from [DataGrid] Addheightprop for sizing without a wrapper #23628 still pass.sxorstyle.minHeightandmaxHeight.maxHeightalready cut printed rows on master (since [DataGrid] Addheightprop for sizing without a wrapper #23628), and the newminHeightwould add a gap below the rows.%,calc(),var()). Content-based keywords such as'auto'are not supported.Argos
docs-data-grid-layout/HeightGridflipped in 7 of 62 builds, and all its header labels moved by 0.5px.HeightGridnow shows the full grid, with both borders, both scrollbars, and the pagination arrows. The new image is byte-identical to the one from build 58453 of [DataGrid] Addheightprop for sizing without a wrapper #23628 (Sep 18). The cut-off image came with the last commit of that PR (2f622ed), which addedflex-shrink: 0.Repro
Master
https://stackblitz.com/edit/v8yzbmhb-nsjn43fk?file=src%2FDemo.tsx

v9.14.0
https://stackblitz.com/edit/v8yzbmhb?file=src%2FDemo.tsx
After fix
https://stackblitz.com/edit/v8yzbmhb-9d8kr8tu?file=src%2FDemo.tsx
Behavior change
sxheight override now also has to setminHeight, because the prop sets it. Before,sx={{ height: 150 }}worked alone, but only below the prop value because ofmaxHeight. The test "should let sx override the height prop" now sets both.heightprop yet (v9.14.0 is older than [DataGrid] Addheightprop for sizing without a wrapper #23628), so no published behavior changes.Generated with Claude Code