diff --git a/src/app/components/SearchBody.svelte b/src/app/components/SearchBody.svelte index 6758e9ea..77a16395 100644 --- a/src/app/components/SearchBody.svelte +++ b/src/app/components/SearchBody.svelte @@ -80,6 +80,14 @@ doSearch(term, controller) } + // The modal container ignores Escape inside a text field, so the focused search input has to + // close the modal itself + const onKeyDown = (event: KeyboardEvent) => { + if (event.key === "Escape") { + popModal() + } + } + const getAgeSection = (createdAt: number) => { const age = now() - createdAt @@ -125,7 +133,8 @@ class="min-w-0 grow" type="text" {placeholder} - oninput={onInput} /> + oninput={onInput} + onkeydown={onKeyDown} /> {#if term} {#if people.length > 0} @@ -135,9 +144,9 @@ {/each} {/if} {#if loading} - Searching... + Searching... {:else if results.length === 0 && people.length === 0} - No results found. + No results found. {:else} {#each eventsByAge as [key, events] (key)}