fix(modal): trigger on keydown instead of keyup to prevent interference

This commit is contained in:
Paul Makles 2023-02-22 17:59:26 +01:00
parent 7d544c82ab
commit 122f047c85
No known key found for this signature in database
GPG key ID: 5059F398521BB0F6

View file

@ -9,7 +9,7 @@ export default observer(() => {
const history = useHistory(); const history = useHistory();
useEffect(() => { useEffect(() => {
function keyUp(event: KeyboardEvent) { function keyDown(event: KeyboardEvent) {
if (event.key === "Escape") { if (event.key === "Escape") {
modalController.pop("close"); modalController.pop("close");
} else if (event.key === "Enter") { } else if (event.key === "Enter") {
@ -18,8 +18,8 @@ export default observer(() => {
} }
} }
document.addEventListener("keyup", keyUp); document.addEventListener("keydown", keyDown);
return () => document.removeEventListener("keyup", keyUp); return () => document.removeEventListener("keydown", keyDown);
}, []); }, []);
return ( return (