How to get the click target when a DropdownMenu or Select is clicked? #2264
-
I'm building an app that adds a click listener to
However, it appears that the radix-ui Is there some other way to get the element that was actually clicked (i.e. in the DropdownMenu.Trigger or Select.Trigger)? Here's a sandbox showing the issue for the DropdownMenu example from the docs: If you click the menu, you can see in the console that the event.target is the element, not the trigger button. Any help is very appreciated, thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
It's because |
Beta Was this translation helpful? Give feedback.
You can listen for
pointerdown
events or control the select viaopen
andonOpenChange
props and openonClick
only. (By doing the second option, you will not be able to select an item in one life cycle click i.e. mouse down, mouse move, mouse up.)