From 1da7ee9e95223c86fe053105a353f0d74ea9b6ff Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Sat, 27 Jun 2020 10:21:50 +1000 Subject: [PATCH] Moved shortcut prevention to all modals --- src/components/Modal.js | 22 ++++++++++++++-------- src/components/map/MapMenu.js | 7 ++++++- src/components/token/TokenMenu.js | 2 -- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/components/Modal.js b/src/components/Modal.js index 94b9eda..8133ef0 100644 --- a/src/components/Modal.js +++ b/src/components/Modal.js @@ -30,14 +30,20 @@ function StyledModal({ }} {...props} > - {children} - {allowClose && ( - - )} + {/* Stop keyboard events when modal is open to prevent shortcuts from triggering */} +
e.stopPropagation()} + onKeyUp={(e) => e.stopPropagation()} + > + {children} + {allowClose && ( + + )} +
); } diff --git a/src/components/map/MapMenu.js b/src/components/map/MapMenu.js index 2c79ddb..a9bebbe 100644 --- a/src/components/map/MapMenu.js +++ b/src/components/map/MapMenu.js @@ -79,7 +79,12 @@ function MapMenu({ }} contentRef={handleModalContent} > - {children} +
e.stopPropagation()} + onKeyUp={(e) => e.stopPropagation()} + > + {children} +
); } diff --git a/src/components/token/TokenMenu.js b/src/components/token/TokenMenu.js index d6d3d91..74ac4e2 100644 --- a/src/components/token/TokenMenu.js +++ b/src/components/token/TokenMenu.js @@ -127,8 +127,6 @@ function TokenMenu({ }, }} autoComplete="off" - onKeyDown={(e) => e.stopPropagation()} - onKeyUp={(e) => e.stopPropagation()} />