Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

Dropdown Menu: list item onSelect is fired sometimes during onClick of the trigger #305

Closed
kyle-platt opened this issue Mar 2, 2021 · 9 comments

Comments

@kyle-platt
Copy link

kyle-platt commented Mar 2, 2021

Sometimes when clicking the trigger to open the dropdown menu list, the onSelect of the 1st or 2nd item in the list is called. This updates the value selected and closes the list immediately.

Expected Result: A click on the trigger button should only open or close the menu list.

Current Outcome: Some clicks on the trigger button cause the onSelect of an item to be triggered.

Screen.Recording.2021-03-02.at.12.07.46.PM.mov
@peduarte
Copy link
Contributor

peduarte commented Mar 2, 2021

Hmm! Thanks for raising this. We have a big PR on the way so I'll see if I can address it there

@kyle-platt
Copy link
Author

Okay great to hear. Thanks!

@kyle-platt
Copy link
Author

Hey @peduarte It looks like that PR was merged. Did anyone get the chance to address this?

@peduarte
Copy link
Contributor

peduarte commented Mar 5, 2021

@kyle-platt I've had to take some time off, but pinging @benoitgrelard to assist.

@benoitgrelard
Copy link
Collaborator

benoitgrelard commented Mar 5, 2021

Hey @kyle-platt I've been trying to reproduce what you're seeing but haven't been able to.
Here's a sandbox with our design system's DropdownMenu:

https://codesandbox.io/s/trusting-mirzakhani-qr58m?file=/src/App.js

If you can fork this and somehow manage to reproduce your issue, that would be very helpful 🙏

@kyle-platt
Copy link
Author

Hey @benoitgrelard here's our component stripped down a bit. Happy to help on this. Let me know if you have any questions or concerns. https://codesandbox.io/s/radix-dropdown-example-gv28o

@benoitgrelard
Copy link
Collaborator

benoitgrelard commented Mar 5, 2021

A few thoughts:

  • It seems you are using the primitives, not the design system, so your issue is in the wrong repo. It should be here instead: https://github.com/radix-ui/primitives
  • I still can't seem to reproduce the issue on your sandbox.
  • On another note, you are trying to create a select out of a dropdown menu. You really shouldn't be doing as these are inherently different wai-aria patterns and thus will cause accessibility issues.

We will soon have a Select primitive which is the correct pattern for what you are trying to achieve.

@kyle-platt
Copy link
Author

@benoitgrelard thank you for the helpful insight. My apologies for the wrong repo. I also wasn't aware of the difference between a select and a dropdown menu. I look forward to playing around with the Select primitive once that's released!

@benoitgrelard
Copy link
Collaborator

Hey @kyle-platt, we have been able to reproduce the issue in a simplified setup.
It seems it's a very particular set of circumstances that produces it.
I've created an issue on the primitives side: radix-ui/primitives#540

Thanks for bringing this to our attention! 🙏

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants