[data grid] Fix hideMenu prop leaking to DOM in GridToolbarExportContainer#22910
Open
mixelburg wants to merge 1 commit into
Open
[data grid] Fix hideMenu prop leaking to DOM in GridToolbarExportContainer#22910mixelburg wants to merge 1 commit into
mixelburg wants to merge 1 commit into
Conversation
…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.
|
Deploy preview: https://deploy-preview-22910--material-ui-x.netlify.app/ Bundle size report
|
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.
Fixes #22909
Problem
GridToolbarExportContainerusesReact.cloneElementto inject ahideMenuprop into all children. When a user passes a bare<MenuItem>(or any component that forwards all props to the DOM),hideMenuleaks onto the DOM<li>element, triggering a React 19 warning:Fix
Remove the
React.cloneElementinjection ofhideMenuinto children. Instead, close the export menu via anonClickhandler on thebaseMenuList. 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 destructurehideMenufrom their own props withhideMenu?.()optional chaining, so receivingundefinedis safe.