mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-13 11:42:10 +00:00
feat: close modal on Esc press
This commit is contained in:
parent
d0d5b5974c
commit
ae364f78ca
1 changed files with 10 additions and 0 deletions
|
@ -38,6 +38,16 @@ export function Modal({
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const close = (e: KeyboardEvent) => {
|
||||||
|
if (e.key === "Escape") {
|
||||||
|
handleCloseClick();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
window.addEventListener("keydown", close);
|
||||||
|
return () => window.removeEventListener("keydown", close);
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
dispatch(toggleDragging(visible));
|
dispatch(toggleDragging(visible));
|
||||||
}, [dispatch, visible]);
|
}, [dispatch, visible]);
|
||||||
|
|
Loading…
Reference in a new issue