Skip to content

Commit 9d64faa

Browse files
committed
Allow opening command palette from Monaco editor
1 parent 92a4515 commit 9d64faa

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

App.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2159,14 +2159,18 @@ const MainApp: React.FC = () => {
21592159
const shortcutMap = getShortcutMap(commands, settings.customShortcuts);
21602160

21612161
const handleKeyDown = (e: KeyboardEvent) => {
2162+
const shortcut = formatShortcut(e);
2163+
const command = shortcutMap.get(shortcut);
2164+
21622165
const activeEl = document.activeElement;
2163-
if (activeEl && ['INPUT', 'TEXTAREA', 'SELECT'].includes(activeEl.tagName) && activeEl !== commandPaletteInputRef.current) {
2166+
const isFormElement = activeEl && ['INPUT', 'TEXTAREA', 'SELECT'].includes(activeEl.tagName);
2167+
const isPaletteInput = activeEl === commandPaletteInputRef.current;
2168+
const isCommandPaletteToggle = command?.id === 'toggle-command-palette';
2169+
2170+
if (isFormElement && !isPaletteInput && !isCommandPaletteToggle) {
21642171
return;
21652172
}
21662173

2167-
const shortcut = formatShortcut(e);
2168-
const command = shortcutMap.get(shortcut);
2169-
21702174
if (command) {
21712175
e.preventDefault();
21722176
command.action();

0 commit comments

Comments
 (0)