diff --git a/src/lib/components/AppLayout.svelte b/src/lib/components/AppLayout.svelte index 485ebf1..94b529e 100644 --- a/src/lib/components/AppLayout.svelte +++ b/src/lib/components/AppLayout.svelte @@ -578,6 +578,11 @@ } if (e.key === 'Escape') { + const dismissesAppUi = $showSettings || $showInfo || $focusMode || $showSearch || $showCommandPalette; + if (!dismissesAppUi) return; + + e.preventDefault(); + e.stopPropagation(); if ($showSettings) $showSettings = false; else if ($showInfo) $showInfo = false; else if ($focusMode) $focusMode = false; diff --git a/src/lib/components/CommandPalette.svelte b/src/lib/components/CommandPalette.svelte index 4b68c00..4fc70c5 100644 --- a/src/lib/components/CommandPalette.svelte +++ b/src/lib/components/CommandPalette.svelte @@ -164,10 +164,15 @@ } }); + function handleEscape(e: KeyboardEvent) { + if (e.key !== 'Escape') return; + e.preventDefault(); + e.stopPropagation(); + $showCommandPalette = false; + } + function handleKeydown(e: KeyboardEvent) { - if (e.key === 'Escape') { - $showCommandPalette = false; - } else if (e.key === 'ArrowDown') { + if (e.key === 'ArrowDown') { e.preventDefault(); selectedIndex = Math.min(selectedIndex + 1, filteredCommands.length - 1); } else if (e.key === 'ArrowUp') { @@ -194,7 +199,7 @@ {#if $showCommandPalette} -
($showCommandPalette = false)} onkeydown={handleKeydown}> +
($showCommandPalette = false)} onkeydowncapture={handleEscape} onkeydown={handleKeydown}>
e.stopPropagation()} onkeydown={(e) => e.stopPropagation()}>
diff --git a/src/lib/components/InfoPanel.svelte b/src/lib/components/InfoPanel.svelte index fdc2969..c7bd212 100644 --- a/src/lib/components/InfoPanel.svelte +++ b/src/lib/components/InfoPanel.svelte @@ -95,6 +95,13 @@ if (event.target === event.currentTarget) close(); } + function handleEscape(event: KeyboardEvent) { + if (event.key !== 'Escape') return; + event.preventDefault(); + event.stopPropagation(); + close(); + } + function openLink(url: string) { openUrl(url).catch(console.error); } @@ -104,7 +111,7 @@ {#if $showInfo} -
{ if (e.key === 'Escape') close(); }}> +

Info

diff --git a/src/lib/components/SearchPanel.svelte b/src/lib/components/SearchPanel.svelte index 1aa346e..64b691a 100644 --- a/src/lib/components/SearchPanel.svelte +++ b/src/lib/components/SearchPanel.svelte @@ -44,10 +44,15 @@ if (item) item.scrollIntoView({ block: 'nearest' }); } + function handleEscape(e: KeyboardEvent) { + if (e.key !== 'Escape') return; + e.preventDefault(); + e.stopPropagation(); + $showSearch = false; + } + function handleKeydown(e: KeyboardEvent) { - if (e.key === 'Escape') { - $showSearch = false; - } else if (e.key === 'ArrowDown') { + if (e.key === 'ArrowDown') { e.preventDefault(); selectedIndex = Math.min(selectedIndex + 1, results.length - 1); scrollToSelected(); @@ -128,7 +133,7 @@ {#if $showSearch} -
+
e.stopPropagation()} onkeydown={(e) => e.stopPropagation()}>
diff --git a/src/lib/components/SettingsPanel.svelte b/src/lib/components/SettingsPanel.svelte index db5223a..0765810 100644 --- a/src/lib/components/SettingsPanel.svelte +++ b/src/lib/components/SettingsPanel.svelte @@ -1068,6 +1068,15 @@ if (event.target === event.currentTarget) close(); } + function handleEscape(event: KeyboardEvent) { + if (event.key !== 'Escape') return; + event.preventDefault(); + event.stopPropagation(); + if (restoreConfirm) restoreConfirm = null; + else if (customThemeEditorOpen) cancelCustomThemeEditor(); + else close(); + } + function dismissRestoreConfirm(event: MouseEvent) { if (event.target === event.currentTarget) restoreConfirm = null; } @@ -1148,7 +1157,7 @@ {#if $showSettings} -
{ if (e.key === 'Escape') close(); }}> +