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
18 changes: 17 additions & 1 deletion app/components/Header/SearchBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@ const showSearchBar = computed(() => {
})

const { model: searchQuery, startSearch } = useGlobalSearch('header')
const hasSearchQuery = computed(() => searchQuery.value.trim().length > 0)

function handleSubmit() {
startSearch()
}

function clearSearch() {
searchQuery.value = ''
inputRef.value?.focus()
}

// Expose focus method for parent components
const inputRef = useTemplateRef('inputRef')
function focus() {
Expand Down Expand Up @@ -52,11 +58,21 @@ defineExpose({ focus })
name="q"
:placeholder="$t('search.placeholder')"
no-correct
class="w-full min-w-25 ps-7"
class="w-full min-w-25 ps-7 pe-8"
@focus="isSearchFocused = true"
@blur="isSearchFocused = false"
size="small"
/>
<button
v-if="hasSearchQuery"
type="button"
class="absolute inset-ie-2 h-6 w-6 items-center justify-center rounded text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent group-focus-within:flex group-hover:inline-flex hidden"
@click="clearSearch"
aria-hidden="true"
tabindex="-1"
>
<span class="i-lucide:circle-x h-4 w-4" />
</button>
<button type="submit" class="sr-only">{{ $t('search.button') }}</button>
</div>
</div>
Expand Down
Loading