@@ -23,21 +23,14 @@ export function useGlobalSearch(place: 'header' | 'content' = 'content') {
2323 return normalizeSearchParam ( route . query . q )
2424 } )
2525
26- // Committed searchQuery: last value submitted by user
27- // Syncs instantly when instant search is on VS only on Enter presswhen off
28- const committedSearchQuery = useState < string > ( 'committed-search-query' , ( ) => {
29- if ( pagesWithLocalFilter . has ( route . name as string ) ) {
30- return ''
31- }
32- return normalizeSearchParam ( route . query . q )
33- } )
26+ // Committed search query: last value submitted by user
27+ // Syncs instantly when instantSearch is on, but only on Enter press when off
28+ const committedSearchQuery = useState < string > ( 'committed-search-query' , ( ) => searchQuery . value )
3429
30+ // This is basically doing instant search as user types
3531 watch ( searchQuery , val => {
3632 if ( settings . value . instantSearch ) {
3733 committedSearchQuery . value = val
38- } else if ( ! val ) {
39- // Only clear committed query when input is cleared
40- committedSearchQuery . value = ''
4134 }
4235 } )
4336
@@ -96,7 +89,8 @@ export function useGlobalSearch(place: 'header' | 'content' = 'content') {
9689 set : async ( value : string ) => {
9790 searchQuery . value = value
9891
99- // When instant search is off, skip debounced URL updates — only flushUpdateUrlQuery commits and navigates
92+ // When instant search is off, skip debounced URL updates
93+ // Only explicitly called flushUpdateUrlQuery commits and navigates
10094 if ( ! settings . value . instantSearch ) return
10195
10296 // Leading debounce implementation as it doesn't work properly out of the box (https://github.com/unjs/perfect-debounce/issues/43)
0 commit comments