From 8a91f2b049a0278eb380631ea43c81fc22cc4779 Mon Sep 17 00:00:00 2001 From: Francois Best Date: Fri, 13 Dec 2024 13:06:57 +0100 Subject: [PATCH] fix: Preserve hash in React Router based adpaters --- packages/nuqs/src/adapters/react-router/v6.ts | 3 ++- packages/nuqs/src/adapters/react-router/v7.ts | 3 ++- packages/nuqs/src/adapters/remix.ts | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/nuqs/src/adapters/react-router/v6.ts b/packages/nuqs/src/adapters/react-router/v6.ts index 14c544c4..2102008b 100644 --- a/packages/nuqs/src/adapters/react-router/v6.ts +++ b/packages/nuqs/src/adapters/react-router/v6.ts @@ -9,7 +9,8 @@ function useNuqsReactRouterV6Adapter() { const updateUrl = (search: URLSearchParams, options: AdapterOptions) => { navigate( { - search: renderQueryString(search) + search: renderQueryString(search), + hash: location.hash }, { replace: options.history === 'replace', diff --git a/packages/nuqs/src/adapters/react-router/v7.ts b/packages/nuqs/src/adapters/react-router/v7.ts index cb5d2bae..934b7db8 100644 --- a/packages/nuqs/src/adapters/react-router/v7.ts +++ b/packages/nuqs/src/adapters/react-router/v7.ts @@ -9,7 +9,8 @@ function useNuqsReactRouterV7Adapter() { const updateUrl = (search: URLSearchParams, options: AdapterOptions) => { navigate( { - search: renderQueryString(search) + search: renderQueryString(search), + hash: location.hash }, { replace: options.history === 'replace', diff --git a/packages/nuqs/src/adapters/remix.ts b/packages/nuqs/src/adapters/remix.ts index 0b6ae64a..4598c341 100644 --- a/packages/nuqs/src/adapters/remix.ts +++ b/packages/nuqs/src/adapters/remix.ts @@ -9,7 +9,8 @@ function useNuqsRemixAdapter() { const updateUrl = (search: URLSearchParams, options: AdapterOptions) => { navigate( { - search: renderQueryString(search) + search: renderQueryString(search), + hash: location.hash }, { replace: options.history === 'replace',