File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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,14 +58,23 @@ 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+ :aria-label =" $t('common.close')"
70+ class =" absolute inset-ie-2 inline-flex 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"
71+ @click =" clearSearch"
72+ >
73+ <span class =" i-lucide:circle-x h-4 w-4" aria-hidden =" true" />
74+ </button >
6075 <button type =" submit" class =" sr-only" >{{ $t('search.button') }}</button >
6176 </div >
6277 </div >
6378 </form >
6479 </search >
65- </template >
80+ </template >
You can’t perform that action at this time.
0 commit comments