Listbox.Options does not stop propagation #2748
Unanswered
TheMythologist
asked this question in
Help
Replies: 1 comment 3 replies
-
Hey, so most events bubble by default – clicks included. This is just how the React (and the web in general) works. Is there a use-case you have detailing why this is a problematic behavior? If I needed to stop the bubbling for whatever reason I would prefer to implement this user-land by adding a click handler (like you did above). Though, I will note that the right thing to use here would be Generally we wouldn't want to stop the events from bubbling unless there was a good reason to do so — e.g. it interferes with the functioning of the component itself. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
What package within Headless UI are you using?
@headlessui/react
What version of that package are you using?
v1.7.16
What browser are you using?
Brave Browser / Chrome
Describe your issue
The selection of an inner
Listbox.Option
does not prevent the event from bubbling into parent components.The current solution to circumvent this is to add
onClick={(e) => e.preventDefault()}
onListbox.Options
Beta Was this translation helpful? Give feedback.
All reactions