Skip to content

Commit 94783f9

Browse files
committed
Prevent default behaviour on palette toggle - fix for windows
1 parent 9ca7b4e commit 94783f9

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/lib/components/CommandPalette.svelte

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
2828
const storeMethods = createStoreMethods();
2929
const actionMap = createActionMap(commands);
30-
let formattedEscKey = ''
30+
let formattedEscKey = '';
3131
const { togglePalette, closePalette: closeCommandPalette } = storeMethods;
3232
3333
const updateStore = () => {
@@ -107,16 +107,21 @@
107107
}
108108
};
109109
110+
const toggleCommandPalette = (event: KeyboardEvent) => {
111+
event.preventDefault();
112+
togglePalette();
113+
};
114+
110115
onMount(async () => {
111-
const tinyKeys = await import('tinykeys')
112-
const {default: tiny, parseKeybinding} = tinyKeys
116+
const tinyKeys = await import('tinykeys');
117+
const { default: tiny, parseKeybinding } = tinyKeys;
113118
formattedEscKey = parseKeybinding('Esc').flat().join('');
114119
const shortcuts = createShortcuts({
115120
actions: commands
116121
});
117122
unsubscribeKbdListener = tiny(window, {
118123
...shortcuts,
119-
'$mod+k': togglePalette,
124+
'$mod+k': toggleCommandPalette,
120125
Escape: closePalette,
121126
ArrowUp: handleArrowUp,
122127
ArrowDown: handleArrowDown,
@@ -161,8 +166,6 @@
161166
focusLastElement();
162167
wrapperElement?.removeEventListener?.('click', handleOutsideClick);
163168
});
164-
165-
166169
</script>
167170

168171
<Portal target="body">

0 commit comments

Comments
 (0)