From 122f047c85519a2a5c791d926372fa55df28992a Mon Sep 17 00:00:00 2001 From: Paul Makles Date: Wed, 22 Feb 2023 17:59:26 +0100 Subject: [PATCH] fix(modal): trigger on keydown instead of keyup to prevent interference --- src/controllers/modals/ModalRenderer.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/controllers/modals/ModalRenderer.tsx b/src/controllers/modals/ModalRenderer.tsx index d53d3c54..147070a9 100644 --- a/src/controllers/modals/ModalRenderer.tsx +++ b/src/controllers/modals/ModalRenderer.tsx @@ -9,7 +9,7 @@ export default observer(() => { const history = useHistory(); useEffect(() => { - function keyUp(event: KeyboardEvent) { + function keyDown(event: KeyboardEvent) { if (event.key === "Escape") { modalController.pop("close"); } else if (event.key === "Enter") { @@ -18,8 +18,8 @@ export default observer(() => { } } - document.addEventListener("keyup", keyUp); - return () => document.removeEventListener("keyup", keyUp); + document.addEventListener("keydown", keyDown); + return () => document.removeEventListener("keydown", keyDown); }, []); return (