primitives icon indicating copy to clipboard operation
primitives copied to clipboard

Dropdown menu does not close if the dropdown menu item contains a Link

Open jainamdoshi opened this issue 1 year ago • 1 comments

Bug report

Dropdown menu does not close if the dropdown menu item (which is clicked) contains a Link component I suspect the link's onClick behaviour overrides/ the dropdown menu item's onClick behaviour.

Current Behavior

A bug example can be seen in these issues #2441 and shadcn-ui/ui#1725

Expected behavior

Should close the dropdown menu when clicked on items which have a Link component

Suggested solution

There is hacky way to fix this issue which is mentioned in shadcn-ui/ui#1725

Your environment

Software Name(s) Version
Radix Package(s) react-dropdown-menu 2.0.6
React n/a 18
Browser Arc 1.30.0
Node n/a 21.6.2
Operating System macOS

jainamdoshi avatar Feb 22 '24 14:02 jainamdoshi

This doesn't look like a Radix issue.

Here's an example using Radix Themes and a Next link:

https://github.com/radix-ui/primitives/assets/1539897/ec033f14-941f-4dab-a8ff-1d1f2e93bbb0

Note that Radix Themes only styles the primitive, doesn't add/modify functionality

Here's the code: CleanShot 2024-02-22 at 14 43 55@2x

benoitgrelard avatar Feb 22 '24 14:02 benoitgrelard

Thanks @benoitgrelard, this makes sense.

jainamdoshi avatar Feb 22 '24 23:02 jainamdoshi