Skip to content

[data grid] Fix hideMenu prop leaking to DOM in GridToolbarExportContainer#22910

Open
mixelburg wants to merge 1 commit into
mui:masterfrom
mixelburg:fix/toolbar-export-hidemenu-prop
Open

[data grid] Fix hideMenu prop leaking to DOM in GridToolbarExportContainer#22910
mixelburg wants to merge 1 commit into
mui:masterfrom
mixelburg:fix/toolbar-export-hidemenu-prop

Conversation

@mixelburg

Copy link
Copy Markdown
Contributor

Fixes #22909

Problem

GridToolbarExportContainer uses React.cloneElement to inject a hideMenu prop into all children. When a user passes a bare <MenuItem> (or any component that forwards all props to the DOM), hideMenu leaks onto the DOM <li> element, triggering a React 19 warning:

React does not recognize the hideMenu prop on a DOM element.

Fix

Remove the React.cloneElement injection of hideMenu into children. Instead, close the export menu via an onClick handler on the baseMenuList. Click events from any child item bubble up to the list and trigger the menu close — same end behavior, no DOM prop leakage.

The built-in export menu items (GridCsvExportMenuItem, GridPrintExportMenuItem) already destructure hideMenu from their own props with hideMenu?.() optional chaining, so receiving undefined is safe.

…rExportContainer

Remove React.cloneElement injection of hideMenu into children. Instead,
close the export menu via onClick on the baseMenuList so that click events
from any child item bubble up and trigger menu close. This prevents
React 19 warnings when children are bare DOM elements (e.g. MenuItem)
that forward all props to the underlying DOM node.
@mui-bot

mui-bot commented Jun 22, 2026

Copy link
Copy Markdown

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

Bundle size report

Bundle Parsed size Gzip size
@mui/x-data-grid ▼-62B(-0.02%) ▼-23B(-0.02%)
@mui/x-data-grid-pro ▼-62B(-0.01%) ▼-21B(-0.01%)
@mui/x-data-grid-premium ▼-62B(-0.01%) ▼-17B(-0.01%)
@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%)

Details of bundle changes

Generated by 🚫 dangerJS against d661016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[data grid] GridToolbarExportContainer leaks the injected hideMenu prop onto the DOM <li>, triggering a React 19 warning

2 participants