mirror of
https://github.com/remvze/moodist.git
synced 2025-09-29 15:30:49 -04:00
refactor: better shortcut handling
This commit is contained in:
parent
98e5021f56
commit
f81ea9e7bd
@ -39,8 +39,8 @@ export function Modal({
|
|||||||
}, [show, lockBody]);
|
}, [show, lockBody]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
function keyListener(e) {
|
function keyListener(e: KeyboardEvent) {
|
||||||
if (e.keyCode === 27) {
|
if (e.key === 'escape') {
|
||||||
onClose();
|
onClose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -48,7 +48,7 @@ export function Modal({
|
|||||||
document.addEventListener('keydown', keyListener);
|
document.addEventListener('keydown', keyListener);
|
||||||
|
|
||||||
return () => document.removeEventListener('keydown', keyListener);
|
return () => document.removeEventListener('keydown', keyListener);
|
||||||
});
|
}, [onClose]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Portal>
|
<Portal>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user