Skip to content

Commit

Permalink
Content search bar auto-selected (#3437)
Browse files Browse the repository at this point in the history
* Content search auto-selected

* Update ContentSearch.svelte

* Update ContentSearch.svelte

---------

Co-authored-by: Ruben Fiszel <[email protected]>
  • Loading branch information
hcourdent and rubenfiszel authored Mar 19, 2024
1 parent 87b0112 commit 24a1ae5
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions frontend/src/lib/components/ContentSearch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,14 @@
let searchKind: 'all' | 'scripts' | 'flows' | 'apps' | 'resources' = 'all'
let isOpen = false
let isOpen = false;
let inputElement;
// Reactive statement to focus the input when the modal opens
$: if (isOpen && inputElement) {
// Use a timeout to ensure focus after any animations or rendering
setTimeout(() => inputElement.focus(), 0);
}
let scripts: undefined | { path: string; content: string }[] = undefined
let filteredScriptItems: { path: string; content: string; marked: any }[] = []
Expand Down Expand Up @@ -87,6 +94,7 @@
flows: getCounts(filteredFlowItems.length),
scripts: getCounts(filteredScriptItems.length)
}
</script>

<SearchItems
Expand Down Expand Up @@ -194,8 +202,8 @@
<div class="relative text-tertiary grow min-w-[100px]">
<!-- svelte-ignore a11y-autofocus -->
<input
autofocus
placeholder={'Search in the content of resources, scripts, flows and apps'}
bind:this={inputElement}
placeholder="Search in the content of resources, scripts, flows and apps"
bind:value={search}
class="bg-surface !h-10 !px-4 !pr-10 !rounded-lg text-sm focus:outline-none"
/>
Expand Down

0 comments on commit 24a1ae5

Please sign in to comment.