File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
src/components/LanguagePicker Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change
1
+ import { useParams } from "next/navigation"
2
+
1
3
import { BaseLink } from "@/components/Link"
2
4
3
5
import { cn } from "@/lib/utils/cn"
@@ -36,6 +38,7 @@ const LanguagePicker = ({
36
38
} : LanguagePickerProps ) => {
37
39
const pathname = usePathname ( )
38
40
const { push } = useRouter ( )
41
+ const params = useParams ( )
39
42
const { disclosure, languages } = useLanguagePicker ( handleClose )
40
43
const { isOpen, setValue, onClose, onOpen } = disclosure
41
44
@@ -52,9 +55,15 @@ const LanguagePicker = ({
52
55
// onClick handlers
53
56
const handleMobileCloseBarClick = ( ) => onClose ( )
54
57
const handleMenuItemSelect = ( currentValue : string ) => {
55
- push ( pathname , {
56
- locale : currentValue ,
57
- } )
58
+ push (
59
+ // @ts -expect-error -- TypeScript will validate that only known `params`
60
+ // are used in combination with a given `pathname`. Since the two will
61
+ // always match for the current route, we can skip runtime checks.
62
+ { pathname, params } ,
63
+ {
64
+ locale : currentValue ,
65
+ }
66
+ )
58
67
onClose ( {
59
68
eventAction : "Locale chosen" ,
60
69
eventName : currentValue ,
You can’t perform that action at this time.
0 commit comments