Skip to content

Commit fe5bbe8

Browse files
committed
remove preventDefault from click handler to let radix update the dropdown state
1 parent 4908116 commit fe5bbe8

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/components/ButtonDropdown.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { MouseEvent, useState } from "react"
1+
import React, { useState } from "react"
22
import { MdMenu } from "react-icons/md"
33

44
import { cn } from "@/lib/utils/cn"
@@ -37,19 +37,14 @@ export type ButtonDropdownProps = {
3737

3838
const ButtonDropdown = ({ list, className }: ButtonDropdownProps) => {
3939
const [selectedItem, setSelectedItem] = useState(list.text)
40-
const handleClick = (
41-
e: MouseEvent<HTMLElement>,
42-
item: ListItem,
43-
idx: number
44-
) => {
40+
const handleClick = (item: ListItem, idx: number) => {
4541
const { matomo, callback } = item
4642

4743
if (matomo) {
4844
trackCustomEvent(matomo)
4945
}
5046

5147
if (callback) {
52-
e.preventDefault()
5348
callback(idx)
5449
}
5550
setSelectedItem(item.text)
@@ -75,7 +70,7 @@ const ButtonDropdown = ({ list, className }: ButtonDropdownProps) => {
7570
<DropdownMenuItem
7671
key={item.text}
7772
className="justify-center"
78-
onClick={(e) => handleClick(e, item, idx)}
73+
onClick={() => handleClick(item, idx)}
7974
asChild
8075
>
8176
<BaseLink
@@ -92,7 +87,7 @@ const ButtonDropdown = ({ list, className }: ButtonDropdownProps) => {
9287
<DropdownMenuItem
9388
key={item.text}
9489
className="justify-center"
95-
onClick={(e) => handleClick(e, item, idx)}
90+
onClick={() => handleClick(item, idx)}
9691
>
9792
<span>{text}</span>
9893
</DropdownMenuItem>

0 commit comments

Comments
 (0)