Skip to content

Commit

Permalink
fix: prevent the escape key from minimizing Safari (#265)
Browse files Browse the repository at this point in the history
* fix: prevent the escape key from minimizing Safari

Safari uses the escape key as a shortcut for exiting full screen.
Stopping propagation is _not_ enough to prevent this behaviour. Use
`preventDefault` instead of `stopPropagation` to avoid messing with the
users' browser experience.

Closes: #264

* fix: stop propagation in addition to preventing default
  • Loading branch information
piofinn authored Dec 3, 2022
1 parent 74bdfb6 commit 6721467
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/InternalEvents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function useToggleHandler() {
Escape: (event: KeyboardEvent) => {
if (showing) {
event.stopPropagation();
event.preventDefault();
options.callbacks?.onClose?.();
}

Expand Down

1 comment on commit 6721467

@vercel
Copy link

@vercel vercel bot commented on 6721467 Dec 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

kbar – ./

kbar-git-main-timc.vercel.app
kbar-timc.vercel.app
kbar.vercel.app

Please sign in to comment.