Skip to content

Allow overriding keyboard handling #670

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Allow overriding keyboard handling
  • Loading branch information
sgoth authored Feb 19, 2024
commit 6b120bac873f3b25d35e885bd4075e25f7986698
6 changes: 6 additions & 0 deletions src/lib/Select.svelte
Original file line number Diff line number Diff line change
@@ -366,6 +366,12 @@
function handleKeyDown(e) {
if (!focused) return;
e.stopPropagation();

// allow users to override our handler
if (!dispatch("keydown", e, { cancelable: true })) {
return;
}

switch (e.key) {
case 'Escape':
e.preventDefault();