Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions packages/site-kit/src/lib/search/SearchBox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ It appears when the user clicks on the `Search` component or presses the corresp
<script lang="ts">
import { afterNavigate } from '$app/navigation';
import { overlay_open, search_query, search_recent, searching } from '../stores';
import { onMount, type Snippet } from 'svelte';
import { onMount, tick, type Snippet } from 'svelte';
import { focusable_children, trap } from '../actions/focus.js';
import Icon from '../components/Icon.svelte';
import SearchResults from './SearchResults.svelte';
Expand Down Expand Up @@ -87,6 +87,11 @@ It appears when the user clicks on the `Search` component or presses the corresp
close();
}

/** The autofocus attribute is insufficient, we need to do this */
function autofocus(node: HTMLInputElement) {
tick().then(() => node.focus());
}

$effect(() => {
if (ready) {
const id = uid++;
Expand Down Expand Up @@ -161,9 +166,8 @@ It appears when the user clicks on the `Search` component or presses the corresp
>
<div class="search-box">
<div style="background: var(--background); padding: 0.5rem">
<!-- svelte-ignore a11y_autofocus -->
<input
autofocus
use:autofocus
onkeydown={(e) => {
if (e.key === 'Enter' && !e.isComposing) {
const element = modal.querySelector('a[data-has-node]') as HTMLElement | undefined;
Expand Down
Loading