Skip to content

Commit

Permalink
Fix "escape" closing multiple modals
Browse files Browse the repository at this point in the history
  • Loading branch information
probablykasper committed Oct 8, 2024
1 parent 5ce4009 commit 5a0a4ec
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/components/Modal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@
$modal_count += 1
onDestroy(() => {
$modal_count -= 1
dialog_el.close()
})
onMount(() => {
dialog_el.showModal()
return () => {
dialog_el.close()
}
})
// Prevent clicks where the mousedown or mouseup happened on a child element. This could've
Expand Down Expand Up @@ -53,8 +51,11 @@
}}
on:keydown
on:keydown={(e) => {
if (check_shortcut(e, 'Escape') && cancel_on_escape) {
on_cancel()
if (check_shortcut(e, 'Escape')) {
e.preventDefault()
if (cancel_on_escape) {
on_cancel()
}
}
}}
on:keydown|self={(e) => {
Expand Down

0 comments on commit 5a0a4ec

Please sign in to comment.