diff --git a/web/hooks/use-sort-and-query-params.tsx b/web/hooks/use-sort-and-query-params.tsx index a2248c2e..5c9a247f 100644 --- a/web/hooks/use-sort-and-query-params.tsx +++ b/web/hooks/use-sort-and-query-params.tsx @@ -53,9 +53,12 @@ export function useInitialQueryAndSort(options?: { console.log('ready loading from storage ', sort ?? defaultSort) const localSort = getSavedSort() if (localSort) { - router.query.s = localSort // Use replace to not break navigating back. - router.replace(router, undefined, { shallow: true }) + router.replace( + { query: { ...router.query, s: localSort } }, + undefined, + { shallow: true } + ) } setInitialSort(localSort ?? defaultSort) } else { @@ -79,7 +82,9 @@ export function useUpdateQueryAndSort(props: { const setSort = (sort: Sort | undefined) => { if (sort !== router.query.s) { router.query.s = sort - router.push(router, undefined, { shallow: true }) + router.replace({ query: { ...router.query, s: sort } }, undefined, { + shallow: true, + }) if (shouldLoadFromStorage) { localStorage.setItem(MARKETS_SORT, sort || '') } @@ -97,7 +102,9 @@ export function useUpdateQueryAndSort(props: { } else { delete router.query.q } - router.push(router, undefined, { shallow: true }) + router.replace({ query: router.query }, undefined, { + shallow: true, + }) track('search', { query }) }, 500), [router]