Delete query param when empty
This commit is contained in:
parent
be01a15230
commit
d6cf4332da
|
@ -104,7 +104,9 @@ export function useQueryAndSortParams(options?: {
|
|||
const pushQuery = useMemo(
|
||||
() =>
|
||||
debounce((query: string | undefined) => {
|
||||
router.replace({ query: { ...router.query, q: query } }, undefined, {
|
||||
const queryObj = { ...router.query, q: query || undefined }
|
||||
if (!query) delete queryObj.q
|
||||
router.replace({ query: queryObj }, undefined, {
|
||||
shallow: true,
|
||||
})
|
||||
}, 100),
|
||||
|
|
Loading…
Reference in New Issue
Block a user