Skip to content

Commit

Permalink
Fix escape handling in Safari
Browse files Browse the repository at this point in the history
  • Loading branch information
probablykasper committed Jan 10, 2024
1 parent 82d07ad commit 51b262f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## Next
- Fix escape handling in Safari

## 1.3.0 - 2024 Jan 10
- Add `class` property
- Fix escape shortcut handling
Expand Down
7 changes: 7 additions & 0 deletions src/lib/Modal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,20 @@
}}
on:keydown
on:keydown={(e) => {
// Escape handling required for Chromium
if (e.key === 'Escape') {
e.preventDefault()
if (!noEscapeHandling) {
onCancel()
}
}
}}
on:cancel={(e) => {
// Escape handling required for Safari
e.preventDefault()
if (noEscapeHandling) return
onCancel()
}}
on:keydown|self={(e) => {
if (form && e.key === 'Enter' && !e.metaKey) {
form()
Expand Down

0 comments on commit 51b262f

Please sign in to comment.