Skip to content

[data grid] Fix the height prop overflowing a narrow flex row parent - #23745

Merged
LukasTy merged 4 commits into
mui:masterfrom
LukasTy:claude/argos-bold-heading-diffs-4f7545
Oct 2, 2026
Merged

LukasTy merged 4 commits into
mui:masterfrom
LukasTy:claude/argos-bold-heading-diffs-4f7545

Conversation

@LukasTy

@LukasTy LukasTy commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Summary

  • With the height prop ([DataGrid] Add height prop for sizing without a wrapper #23628), the root uses 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 again. The prop sets minHeight and maxHeight, which hold the height in a flex column parent. The flex column tests from [DataGrid] Add height prop for sizing without a wrapper #23628 still pass.
  • New browser test: a 300px flex row parent with one 500px column. It fails on master (the root is wider than 300px) and passes with this change.
  • Docs: the "Height prop" section now tells users to change the height through the prop, not sx or style.
  • Print export: the printed copy of the grid now resets minHeight and maxHeight. maxHeight already cut printed rows on master (since [DataGrid] Add height prop for sizing without a wrapper #23628), and the new minHeight would add a gap below the rows.
  • Docs and JSDoc: list the supported height values (number, CSS length, %, calc(), var()). Content-based keywords such as 'auto' are not supported.

Argos

  • This removes the last repeated Argos flake after [test] Make regression screenshot rasterization deterministic #23722. docs-data-grid-layout/HeightGrid flipped in 7 of 62 builds, and all its header labels moved by 0.5px.
  • Cause: the grid stayed 717px wide in the 500px centered regression box, so it sat at x = -100.5. At that half pixel, Chromium rounds the origin of the sticky header layer to -99 or -100. The result depends on the route that the pooled page rendered before.
  • With this change, the grid fits the box at x = 8. In 70 local runs with the CI flags and 15px scrollbars, the screenshots differ by at most 1 color level, at the rounded corners only. Argos ignores that. Before the change, the header text differed by up to 191 levels.
  • Expect one Argos change: HeightGrid now 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] Add height prop for sizing without a wrapper #23628 (Sep 18). The cut-off image came with the last commit of that PR (2f622ed), which added flex-shrink: 0.

Repro

Master

https://stackblitz.com/edit/v8yzbmhb-nsjn43fk?file=src%2FDemo.tsx
data-grid-height-master

v9.14.0

https://stackblitz.com/edit/v8yzbmhb?file=src%2FDemo.tsx

data-grid-height-9-14-0

After fix

https://stackblitz.com/edit/v8yzbmhb-9d8kr8tu?file=src%2FDemo.tsx

data-grid-height-after-fix

Behavior change

  • An sx height override now also has to set minHeight, because the prop sets it. Before, sx={{ height: 150 }} worked alone, but only below the prop value because of maxHeight. The test "should let sx override the height prop" now sets both.
  • No release has the height prop yet (v9.14.0 is older than [DataGrid] Add height prop for sizing without a wrapper #23628), so no published behavior changes.

Generated with Claude Code

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>
@LukasTy LukasTy added type: bug It doesn't behave as expected. scope: data grid Changes related to the data grid. labels Oct 2, 2026
@code-infra-dashboard

code-infra-dashboard Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Deploy preview

Bundle size

Bundle Parsed size Gzip size
@mui/x-data-grid 🔺+31B(+0.01%) 🔺+5B(0.00%)
@mui/x-data-grid-pro 🔺+31B(+0.01%) 🔺+8B(0.00%)
@mui/x-data-grid-premium 🔺+31B(0.00%) 🔺+6B(0.00%)
@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-scheduler 0B(0.00%) 0B(0.00%)
@mui/x-scheduler-premium 0B(0.00%) 0B(0.00%)
@mui/x-chat 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.

@LukasTy
LukasTy requested review from JCQuintas and michelengelen and a balanced review from Copilot October 2, 2026 13:27
@LukasTy LukasTy self-assigned this Oct 2, 2026
@LukasTy

LukasTy commented Oct 2, 2026

Copy link
Copy Markdown
Member Author

@JCQuintas, @michelengelen could you check if this is a potential regression that I keep postponing the release for?

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.

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 JCQuintas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, seems to be working
https://stackblitz.com/edit/pztmqw9c?file=src%2Fmain.jsx

Thanks for the fix

@LukasTy
LukasTy merged commit 1ab7b9c into mui:master Oct 2, 2026
23 checks passed
@LukasTy
LukasTy deleted the claude/argos-bold-heading-diffs-4f7545 branch October 2, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: data grid Changes related to the data grid. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants