diff --git a/packages/mui-material/src/Modal/Modal.js b/packages/mui-material/src/Modal/Modal.js index 60d29549ff74ae..bbb78393680047 100644 --- a/packages/mui-material/src/Modal/Modal.js +++ b/packages/mui-material/src/Modal/Modal.js @@ -156,6 +156,7 @@ const Modal = React.forwardRef(function Modal(inProps, ref) { } const externalForwardedProps = { + ...other, slots: { root: components.Root, backdrop: components.Backdrop, @@ -218,7 +219,7 @@ const Modal = React.forwardRef(function Modal(inProps, ref) { * is not meant for humans to interact with directly. * https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-static-element-interactions.md */} - + {!hideBackdrop && BackdropComponent ? ( ) : null} diff --git a/packages/mui-material/src/Modal/Modal.test.js b/packages/mui-material/src/Modal/Modal.test.js index dd4da576fde15f..872a5e18460c73 100644 --- a/packages/mui-material/src/Modal/Modal.test.js +++ b/packages/mui-material/src/Modal/Modal.test.js @@ -880,4 +880,20 @@ describe('', () => { ); }).not.toErrorDev(); }); + + it('should not override default onKeyDown', async () => { + const handleKeyDown = spy(); + const handleClose = spy(); + + const { user } = render( + +
+ , + ); + + await user.keyboard('{Escape}'); + + expect(handleKeyDown).to.have.property('callCount', 1); + expect(handleClose).to.have.property('callCount', 1); + }); });