Conversation
…totype property names
The row-tree builder used plain `{}` objects as hash maps keyed by
user-supplied grouping values. Looking up `'constructor'` (or
`'__proto__'`, `'toString'`, etc.) returned the inherited
`Object.prototype` property instead of `undefined`, so the code thought
a node already existed at that path and crashed when it tried to use
the prototype function as a node id.
Switch the `childrenFromPath` lookup objects to `Object.create(null)`
so user-supplied keys can never collide with `Object.prototype`. This
matches existing usage in the sorting/filter selectors.
Backport of mui#22312 to v7.
Fixes mui#22310
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Deploy preview: https://deploy-preview-22344--material-ui-x.netlify.app/ |
Member
Author
|
Verified the fix solves the issue locally, since on v7 we no longer have PR package builds. |
michelengelen
approved these changes
May 6, 2026
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.
Backport of #22312 to v7.x. Fixes #22310 on v7.
Summary
The Data Grid (Pro & Premium) crashed with a white screen when a row-grouping value or tree-data path segment was equal to
'constructor'(or any otherObject.prototypeproperty name like'__proto__','toString','hasOwnProperty','valueOf').The root cause is identical on v7.x as on master:
childrenFromPathlookup objects were plain{}, so reading({}).constructorreturnedObject.prototype.constructorinstead ofundefined. The tree builder then treated that function as an existing node id and crashed.Differences from #22312
The master PR also patches
treeDataReorderExecutor.ts, but that file does not exist on v7.x (the tree-data drag-and-drop reorder feature was added later). All other source-level changes are identical. Tests are ported to mocha + chai to match v7's test stack.Files touched
packages/x-data-grid/src/hooks/features/rows/gridRowsUtils.ts(root group)packages/x-data-grid-pro/src/utils/tree/insertDataRowInTree.ts(3 group node construction sites)packages/x-data-grid-pro/src/utils/tree/utils.ts(inner per-field map ininsertNodeInTree)Test plan
New regression test in
rowGrouping.DataGridPremium.test.tsxfor row grouping with'constructor','__proto__','toString','hasOwnProperty'as grouping values.New regression test in
treeData.DataGridPro.test.tsxfor tree-data paths starting with'constructor'.mocha 'packages/x-data-grid-pro/src/tests/treeData.DataGridPro.test.tsx'(45 passing).mocha 'packages/x-data-grid-premium/src/tests/rowGrouping.DataGridPremium.test.tsx'(104 passing; one pre-existing flake in an unrelated sorting test reproduces on plain v7.x without this change).pnpm --filter "@mui/x-data-grid*" run typescript.pnpm prettier, eslint clean on touched files.Maintainer to verify against the reporter's CodeSandbox.