From 2c432b57e71315c70046f89974204cfe173f7ffc Mon Sep 17 00:00:00 2001 From: dtonon Date: Wed, 12 Aug 2026 22:24:11 +0100 Subject: [PATCH] Route stray keystrokes into the search modal input --- src/lib/components/SearchModal.svelte | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/lib/components/SearchModal.svelte b/src/lib/components/SearchModal.svelte index 1fa474e..923d26b 100644 --- a/src/lib/components/SearchModal.svelte +++ b/src/lib/components/SearchModal.svelte @@ -27,7 +27,20 @@ // Global "/" opens the search from any page, unless typing somewhere else function onWindowKeydown(e: KeyboardEvent) { if (searchModal.open) { - if (e.key === "Escape") closeSearch(); + if (e.key === "Escape") { + closeSearch(); + return; + } + // Typing fast right after "/" can outrun the async focus; route the + // keystroke into the input so no leading characters get lost + if ( + e.key.length === 1 && + !e.metaKey && + !e.ctrlKey && + !e.altKey && + document.activeElement !== inputEl + ) + inputEl?.focus(); return; } if (e.key !== "/" || e.metaKey || e.ctrlKey || e.altKey) return;