Skip to content

Commit 2ba1c5e

Browse files
authored
fix: correct search condition for routing (#1574)
1 parent f1cc98f commit 2ba1c5e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-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: 2 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

0 commit comments

Comments
 (0)