Skip to content

Commit 3349ecc

Browse files
committed
fix: correct search condition for routing
1 parent 63d5d59 commit 3349ecc

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

app/components/Header/SearchBox.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const showSearchBar = computed(() => {
1616
return route.name !== 'index'
1717
})
1818
19-
const { model: searchQuery, flushUpdateUrlQuery } = useGlobalSearch()
19+
const { model: searchQuery, flushUpdateUrlQuery } = useGlobalSearch('header')
2020
2121
function handleSubmit() {
2222
flushUpdateUrlQuery()

app/composables/useGlobalSearch.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { debounce } from 'perfect-debounce'
44
// Pages that have their own local filter using ?q
55
const pagesWithLocalFilter = new Set(['~username', 'org'])
66

7-
export function useGlobalSearch() {
7+
export function useGlobalSearch(place: 'header' | 'content' = 'content') {
88
const { searchProvider } = useSearchProvider()
99
const searchProviderValue = computed(() => {
1010
const p = normalizeSearchParam(route.query.p)
@@ -32,7 +32,7 @@ export function useGlobalSearch() {
3232
const updateUrlQueryImpl = (value: string, provider: 'npm' | 'algolia') => {
3333
const isSameQuery = route.query.q === value && route.query.p === provider
3434
// Don't navigate away from pages that use ?q for local filtering
35-
if (pagesWithLocalFilter.has(route.name as string) || isSameQuery) {
35+
if ((pagesWithLocalFilter.has(route.name as string) && place === 'content') || isSameQuery) {
3636
return
3737
}
3838

@@ -64,6 +64,7 @@ export function useGlobalSearch() {
6464
get: () => searchQuery.value,
6565
set: async (value: string) => {
6666
searchQuery.value = value
67+
console.log('searchQueryValue', value, updateUrlQuery.isPending())
6768

6869
// Leading debounce implementation as it doesn't work properly out of the box (https://github.com/unjs/perfect-debounce/issues/43)
6970
if (!updateUrlQuery.isPending()) {

0 commit comments

Comments
 (0)