File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -107,6 +107,7 @@ onKeyStroke(
107107 <div
108108 class =" flex-1 flex items-center justify-center md:gap-6"
109109 :class =" { 'hidden sm:flex': !isSearchExpanded }"
110+ v-if =" !isOnHomePage"
110111 >
111112 <!-- Search bar (hidden on mobile unless expanded) -->
112113 <HeaderSearchBox
Original file line number Diff line number Diff line change @@ -21,9 +21,13 @@ const showSearchBar = computed(() => {
2121
2222// Local input value (updates immediately as user types)
2323const searchQuery = shallowRef (' ' )
24- onMounted (() => {
25- searchQuery .value = normalizeSearchParam (route .query .q )
26- })
24+ watch (
25+ () => route .query .q ,
26+ query => {
27+ searchQuery .value = normalizeSearchParam (query )
28+ },
29+ { immediate: true },
30+ )
2731
2832// Pages that have their own local filter using ?q
2933const pagesWithLocalFilter = new Set ([' ~username' , ' org' ])
@@ -57,6 +61,13 @@ function handleSearchFocus() {
5761}
5862
5963const inputRef = useTemplateRef (' inputRef' )
64+ function focus() {
65+ const input = inputRef .value
66+ if (input ) {
67+ input .focus ()
68+ input .setSelectionRange (input .value .length , input .value .length )
69+ }
70+ }
6071
6172function handleSubmit() {
6273 if (pagesWithLocalFilter .has (route .name as string )) {
@@ -70,13 +81,12 @@ function handleSubmit() {
7081 updateUrlQuery (searchQuery .value )
7182 }
7283
73- inputRef . value ?. focus ()
84+ focus ()
7485}
7586
87+ onMounted (focus )
88+
7689// Expose focus method for parent components
77- function focus() {
78- inputRef .value ?.focus ()
79- }
8090defineExpose ({ focus })
8191 </script >
8292<template >
You can’t perform that action at this time.
0 commit comments