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:
parent
1a64075027
commit
5b241f0b64
1 changed files with 8 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue