File tree 3 files changed +47
-1
lines changed
3 files changed +47
-1
lines changed Original file line number Diff line number Diff line change
1
+ /// <reference types="cypress" />
2
+
3
+ describe ( 'repro-758' , ( ) => {
4
+ it ( 'honors urlKeys when navigating back after a push' , ( ) => {
5
+ cy . visit ( '/app/repro-758' )
6
+ cy . contains ( '#hydration-marker' , 'hydrated' ) . should ( 'be.hidden' )
7
+ cy . get ( 'button' ) . click ( )
8
+ cy . get ( '#state' ) . should ( 'have.text' , 'test' )
9
+ cy . go ( 'back' )
10
+ cy . get ( '#state' ) . should ( 'be.empty' )
11
+ } )
12
+ } )
Original file line number Diff line number Diff line change
1
+ 'use client'
2
+
3
+ import { parseAsString , useQueryStates } from 'nuqs'
4
+ import { Suspense } from 'react'
5
+
6
+ export default function Page ( ) {
7
+ return (
8
+ < Suspense >
9
+ < Client />
10
+ </ Suspense >
11
+ )
12
+ }
13
+
14
+ function Client ( ) {
15
+ const [ { query } , setSearchParams ] = useQueryStates (
16
+ {
17
+ query : parseAsString
18
+ } ,
19
+ {
20
+ history : 'push' ,
21
+ urlKeys : {
22
+ query : 'q'
23
+ }
24
+ }
25
+ )
26
+ return (
27
+ < >
28
+ < button onClick = { ( ) => setSearchParams ( { query : 'test' } ) } >
29
+ Set query
30
+ </ button >
31
+ < p id = "state" > { query } </ p >
32
+ </ >
33
+ )
34
+ }
Original file line number Diff line number Diff line change @@ -123,7 +123,7 @@ export function useQueryStates<KeyMap extends UseQueryStatesKeysMap>(
123
123
)
124
124
setInternalState ( state )
125
125
} , [
126
- Object . keys ( resolvedUrlKeys )
126
+ Object . values ( resolvedUrlKeys )
127
127
. map ( key => initialSearchParams ?. get ( key ) )
128
128
. join ( '&' )
129
129
] )
You can’t perform that action at this time.
0 commit comments