Skip to content

Commit 45fb6ca

Browse files
fix: nested modals correctly close with the escpape key (including animations)
1 parent 2f4c42d commit 45fb6ca

File tree

1 file changed

+5
-1
lines changed
  • packages/kit-headless/src/components/modal

1 file changed

+5
-1
lines changed

packages/kit-headless/src/components/modal/modal.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,15 @@ export const Modal = component$((props: ModalProps) => {
7676
});
7777

7878
const handleKeyDownSync$ = sync$((e: KeyboardEvent) => {
79-
const keys = [' ', 'Enter', 'Escape'];
79+
const keys = [' ', 'Enter'];
8080

8181
if (e.target instanceof HTMLDialogElement && keys.includes(e.key)) {
8282
e.preventDefault();
8383
}
84+
85+
if (e.key === 'Escape') {
86+
e.preventDefault();
87+
}
8488
});
8589

8690
const handleKeyDown$ = $((e: KeyboardEvent) => {

0 commit comments

Comments
 (0)