diff --git a/src/common/ModalDialog/ModalDialog.js b/src/common/ModalDialog/ModalDialog.js index bfcc247ef..ae1cf0851 100644 --- a/src/common/ModalDialog/ModalDialog.js +++ b/src/common/ModalDialog/ModalDialog.js @@ -34,9 +34,9 @@ const ModalDialog = ({ className, title, buttons, children, dataset, onCloseRequ event.nativeEvent.closeModalDialogPrevented = true; }, []); React.useEffect(() => { - const onWindowKeyDown = (event) => { + const onKeyDown = (event) => { // its `-2` because focus lock render locking divs around its content - if (event.key === 'Escape' && modalsContainer.childNodes[modalsContainer.childElementCount - 2] === modalContainerRef.current) { + if (event.code === 'Escape' && modalsContainer.childNodes[modalsContainer.childElementCount - 2] === modalContainerRef.current) { if (typeof onCloseRequest === 'function') { onCloseRequest({ type: 'close', @@ -46,9 +46,9 @@ const ModalDialog = ({ className, title, buttons, children, dataset, onCloseRequ } } }; - window.addEventListener('keydown', onWindowKeyDown); + window.addEventListener('keydown', onKeyDown); return () => { - window.removeEventListener('keydown', onWindowKeyDown); + window.removeEventListener('keydown', onKeyDown); }; }, [dataset, onCloseRequest]); return ( diff --git a/src/common/Popup/Popup.js b/src/common/Popup/Popup.js index 1df4192b4..cf22cda08 100644 --- a/src/common/Popup/Popup.js +++ b/src/common/Popup/Popup.js @@ -24,7 +24,7 @@ const Popup = ({ open, direction, renderLabel, renderMenu, dataset, onCloseReque onCloseRequest(closeEvent); break; case 'keydown': - if (event.key === 'Escape') { + if (event.code === 'Escape') { onCloseRequest(closeEvent); } break;