Skip to content

Commit 588c8b6

Browse files
diegorvclaude
andcommitted
fix(settings): use window-level keydown for Escape to close panel
Context: SettingsPanel used `onkeydown` on the panel div, but the div never receives focus automatically when it opens. Escape key events go to whatever element has focus (usually the editor), so the handler never fires. Solution: Move the Escape handler to `svelte:window onkeydown` so it captures the key regardless of focus state. Guard with `isOpen` check to avoid closing when already closed. Files: - src/lib/core/settings/SettingsPanel.svelte (77-81,83,86-93): replaced div-level onkeydown with svelte:window onkeydown, removed tabindex and a11y ignore comment (no longer needed) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent f93a276 commit 588c8b6

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

src/lib/core/settings/SettingsPanel.svelte

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,22 +75,21 @@
7575
});
7676
7777
function handleKeydown(event: KeyboardEvent) {
78-
if (event.key === 'Escape') {
78+
if (event.key === 'Escape' && settingsPanelStore.isOpen) {
7979
settingsPanelStore.close();
8080
}
8181
}
8282
</script>
8383

84+
<svelte:window onkeydown={handleKeydown} />
85+
8486
{#if settingsPanelStore.isOpen}
85-
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
8687
<div
8788
class="fixed top-0 right-0 z-40 flex flex-row overflow-hidden border-l border-border bg-settings-dialog-bg shadow-[-4px_0_12px_rgba(0,0,0,0.15)]"
8889
style="bottom: 24px; width: 820px; max-width: 80vw;"
8990
transition:fly={{ x: 820, duration: 200 }}
9091
role="dialog"
9192
aria-label="Settings"
92-
tabindex="-1"
93-
onkeydown={handleKeydown}
9493
>
9594
<!-- Sidebar -->
9695
<nav class="flex w-48 shrink-0 flex-col gap-0.5 overflow-y-auto border-r border-border px-3 py-5 bg-settings-sidebar-bg">

0 commit comments

Comments
 (0)