diff --git a/web/hooks/use-query-params.spec.tsx b/web/hooks/use-query-params.spec.tsx index dc7fe4d2b3..2ce8f63156 100644 --- a/web/hooks/use-query-params.spec.tsx +++ b/web/hooks/use-query-params.spec.tsx @@ -119,7 +119,7 @@ describe('useQueryParams hooks', () => { expect(update.searchParams.has(PRICING_MODAL_QUERY_PARAM)).toBe(false) }) - it('should use replace history when closing', async () => { + it('should use push history when closing', async () => { // Arrange const { result, onUrlUpdate } = renderWithAdapter( () => usePricingModal(), @@ -134,7 +134,7 @@ describe('useQueryParams hooks', () => { // Assert await waitFor(() => expect(onUrlUpdate).toHaveBeenCalled()) const update = onUrlUpdate.mock.calls[onUrlUpdate.mock.calls.length - 1][0] - expect(update.options.history).toBe('replace') + expect(update.options.history).toBe('push') }) it('should respect explicit history options when provided', async () => { diff --git a/web/hooks/use-query-params.ts b/web/hooks/use-query-params.ts index 6565846067..de984c8512 100644 --- a/web/hooks/use-query-params.ts +++ b/web/hooks/use-query-params.ts @@ -34,6 +34,8 @@ const parseAsPricingModal = createParser({ parse: value => (value === PRICING_MODAL_QUERY_VALUE ? true : null), serialize: value => (value ? PRICING_MODAL_QUERY_VALUE : ''), }) + .withDefault(false) + .withOptions({ history: 'push' }) /** * Hook to manage pricing modal state via URL @@ -47,13 +49,12 @@ const parseAsPricingModal = createParser({ export function usePricingModal() { const [isOpen, setIsOpenState] = useQueryState( PRICING_MODAL_QUERY_PARAM, - parseAsPricingModal.withDefault(false), + parseAsPricingModal, ) const setIsOpen = useCallback( (open: boolean, options?: Options) => { - const history = options?.history ?? (open ? 'push' : 'replace') - setIsOpenState(open ? true : null, { ...options, history }) + setIsOpenState(open, options) }, [setIsOpenState], )