1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-01-01 08:31:59 +00:00

feat(web): Allow closing modals with Escape key (#2257)

This commit is contained in:
bo0tzz 2023-04-15 18:51:56 +02:00 committed by GitHub
parent 1a64075027
commit 5b241f0b64
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,11 +6,19 @@ export function clickOutside(node: Node) {
}
};
const handleKey = (event: KeyboardEvent) => {
if (event.key == 'Escape') {
node.dispatchEvent(new CustomEvent('outclick'));
}
};
document.addEventListener('click', handleClick, true);
document.addEventListener('keydown', handleKey, true);
return {
destroy() {
document.removeEventListener('click', handleClick, true);
document.removeEventListener('keydown', handleKey, true);
}
};
}