Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content search bar auto-selected #3437

Merged
merged 3 commits into from
Mar 19, 2024
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
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
Loading