File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
packages/mui-material/src/Modal Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -156,6 +156,7 @@ const Modal = React.forwardRef(function Modal(inProps, ref) {
156156 }
157157
158158 const externalForwardedProps = {
159+ ...other ,
159160 slots : {
160161 root : components . Root ,
161162 backdrop : components . Backdrop ,
@@ -218,7 +219,7 @@ const Modal = React.forwardRef(function Modal(inProps, ref) {
218219 * is not meant for humans to interact with directly.
219220 * https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-static-element-interactions.md
220221 */ }
221- < RootSlot { ...rootProps } { ... other } >
222+ < RootSlot { ...rootProps } >
222223 { ! hideBackdrop && BackdropComponent ? (
223224 < BackdropSlot { ...backdropProps } ref = { backdropRef } />
224225 ) : null }
Original file line number Diff line number Diff line change @@ -880,4 +880,20 @@ describe('<Modal />', () => {
880880 ) ;
881881 } ) . not . toErrorDev ( ) ;
882882 } ) ;
883+
884+ it ( 'should not override default onKeyDown' , async ( ) => {
885+ const handleKeyDown = spy ( ) ;
886+ const handleClose = spy ( ) ;
887+
888+ const { user } = render (
889+ < Modal open onKeyDown = { handleKeyDown } onClose = { handleClose } >
890+ < div tabIndex = { - 1 } />
891+ </ Modal > ,
892+ ) ;
893+
894+ await user . keyboard ( '{Escape}' ) ;
895+
896+ expect ( handleKeyDown ) . to . have . property ( 'callCount' , 1 ) ;
897+ expect ( handleClose ) . to . have . property ( 'callCount' , 1 ) ;
898+ } ) ;
883899} ) ;
You can’t perform that action at this time.
0 commit comments