Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/components/Header/SearchBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const showSearchBar = computed(() => {
return route.name !== 'index'
})

const { model: searchQuery, flushUpdateUrlQuery } = useGlobalSearch()
const { model: searchQuery, flushUpdateUrlQuery } = useGlobalSearch('header')

function handleSubmit() {
flushUpdateUrlQuery()
Expand Down
5 changes: 3 additions & 2 deletions app/composables/useGlobalSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { debounce } from 'perfect-debounce'
// Pages that have their own local filter using ?q
const pagesWithLocalFilter = new Set(['~username', 'org'])

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

Expand Down Expand Up @@ -64,6 +64,7 @@ export function useGlobalSearch() {
get: () => searchQuery.value,
set: async (value: string) => {
searchQuery.value = value
console.log('searchQueryValue', value, updateUrlQuery.isPending())
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

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