Moved shortcut prevention to all modals

This commit is contained in:
Mitchell McCaffrey 2020-06-27 10:21:50 +10:00
parent 62587e471a
commit 1da7ee9e95
3 changed files with 20 additions and 11 deletions

View File

@ -30,14 +30,20 @@ function StyledModal({
}}
{...props}
>
{children}
{allowClose && (
<Close
m={0}
sx={{ position: "absolute", top: 0, right: 0 }}
onClick={onRequestClose}
/>
)}
{/* Stop keyboard events when modal is open to prevent shortcuts from triggering */}
<div
onKeyDown={(e) => e.stopPropagation()}
onKeyUp={(e) => e.stopPropagation()}
>
{children}
{allowClose && (
<Close
m={0}
sx={{ position: "absolute", top: 0, right: 0 }}
onClick={onRequestClose}
/>
)}
</div>
</Modal>
);
}

View File

@ -79,7 +79,12 @@ function MapMenu({
}}
contentRef={handleModalContent}
>
{children}
<div
onKeyDown={(e) => e.stopPropagation()}
onKeyUp={(e) => e.stopPropagation()}
>
{children}
</div>
</Modal>
);
}

View File

@ -127,8 +127,6 @@ function TokenMenu({
},
}}
autoComplete="off"
onKeyDown={(e) => e.stopPropagation()}
onKeyUp={(e) => e.stopPropagation()}
/>
</Flex>
<Box