[dialog][modal] Remove disableEscapeKeyDown prop#47695
[dialog][modal] Remove disableEscapeKeyDown prop#47695silviuaavram merged 8 commits intomui:masterfrom
disableEscapeKeyDown prop#47695Conversation
Netlify deploy previewBundle size report
|
There was a problem hiding this comment.
Pull request overview
This PR removes the disableEscapeKeyDown prop from Modal, Dialog, and useModal components, aligning with the previous removal of disableBackdropClick. Users should now handle escape key behavior by checking the reason parameter in the onClose callback, providing a more consistent and flexible API design.
Changes:
- Removed
disableEscapeKeyDownprop from Modal, Dialog, and useModal type definitions and implementations - Updated tests to demonstrate the new pattern of handling escape key behavior via the
onClosecallback - Updated API documentation JSON files and examples to remove references to the deprecated prop
Reviewed changes
Copilot reviewed 10 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/mui-material/src/Modal/useModal.types.ts | Removed disableEscapeKeyDown prop type definition |
| packages/mui-material/src/Modal/useModal.ts | Removed conditional check for disableEscapeKeyDown, now always calls onClose with escapeKeyDown reason |
| packages/mui-material/src/Modal/Modal.test.js | Updated tests to show how to disable escape key behavior via onClose callback filtering |
| packages/mui-material/src/Modal/Modal.js | Removed disableEscapeKeyDown prop and its PropTypes definition |
| packages/mui-material/src/Modal/Modal.d.ts | Removed disableEscapeKeyDown from TypeScript interface |
| packages/mui-material/src/Dialog/Dialog.test.js | Updated test to filter both backdropClick and escapeKeyDown in the onClose handler |
| packages/mui-material/src/Dialog/Dialog.js | Removed disableEscapeKeyDown prop, its default value, and PropTypes definition |
| packages/mui-material/src/Dialog/Dialog.d.ts | Removed disableEscapeKeyDown from TypeScript interface |
| docs/pages/material-ui/api/modal.json | Removed disableEscapeKeyDown from API documentation |
| docs/pages/material-ui/api/dialog.json | Removed disableEscapeKeyDown from API documentation |
| docs/data/material/components/selects/DialogSelect.tsx | Updated example to filter both backdropClick and escapeKeyDown in handleClose, removed disableEscapeKeyDown prop usage |
| docs/data/material/components/selects/DialogSelect.js | Updated example to filter both backdropClick and escapeKeyDown in handleClose, removed disableEscapeKeyDown prop usage |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ZeeshanTamboli
left a comment
There was a problem hiding this comment.
We should also add this in the upgrade to v9 docs: https://github.com/mui/material-ui/blob/master/docs/data/material/migration/upgrade-to-v9/upgrade-to-v9.md.
siriwatknp
left a comment
There was a problem hiding this comment.
Please update this page https://next.mui.com/material-ui/migration/upgrade-to-v9/ to include this breaking change with the migration.
4028856 to
8386e95
Compare
06f5c0a to
b4911ac
Compare
disableEscapeKeyDown prop
Remove the
disableEscapeKeyDownfromuseModal,ModalandDialog. Change the tests to reflect the change. Change the API docs and relevant examples.Fixes #27306.