File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -17,11 +17,17 @@ const showSearchBar = computed(() => {
1717})
1818
1919const { model : searchQuery, startSearch } = useGlobalSearch (' header' )
20+ const hasSearchQuery = computed (() => searchQuery .value .trim ().length > 0 )
2021
2122function handleSubmit() {
2223 startSearch ()
2324}
2425
26+ function clearSearch() {
27+ searchQuery .value = ' '
28+ inputRef .value ?.focus ()
29+ }
30+
2531// Expose focus method for parent components
2632const inputRef = useTemplateRef (' inputRef' )
2733function focus() {
@@ -52,11 +58,21 @@ defineExpose({ focus })
5258 name =" q"
5359 :placeholder =" $t('search.placeholder')"
5460 no-correct
55- class =" w-full min-w-25 ps-7"
61+ class =" w-full min-w-25 ps-7 pe-8 "
5662 @focus =" isSearchFocused = true"
5763 @blur =" isSearchFocused = false"
5864 size =" small"
5965 />
66+ <button
67+ v-if =" hasSearchQuery"
68+ type =" button"
69+ 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"
70+ @click =" clearSearch"
71+ aria-hidden =" true"
72+ tabindex =" -1"
73+ >
74+ <span class =" i-lucide:circle-x h-4 w-4" />
75+ </button >
6076 <button type =" submit" class =" sr-only" >{{ $t('search.button') }}</button >
6177 </div >
6278 </div >
You can’t perform that action at this time.
0 commit comments