feat: close modal on Esc press

This commit is contained in:
Fernando Zanutto 2024-04-23 09:34:07 -03:00
parent fe17b2f50e
commit 3603fc29fd

View File

@ -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(() => {
dispatch(toggleDragging(visible));
}, [dispatch, visible]);