-
-
Notifications
You must be signed in to change notification settings - Fork 79k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow click events within dropdown #34396
base: main
Are you sure you want to change the base?
Conversation
Closing pending further testing |
I'm not sure why the toggle elements have "preventDefault()" on them. No tests are using such behavior. Is there a clarifying reason? From my viewpoint, it just prevents dropdown toggles from having additional functionality (e.g. inside of the dropdown) |
Using You can use a split dropdown for this like so https://jsfiddle.net/wguzqj8L/ |
@XhmikosR should we close this as won't fix or do we want to risk undesirable side effects like changing the url hash when using |
Perhaps another option is controlling this with a new parameter data-bs-prevent-click default true? Ya, I already hate this idea, and I'm sure you will too. Just trying to come up with a method to allow this component to actually be useful to me... I still think that the preventDefault() is unnecessary as, at best, it just fixes bad HTML which can just be rewritten to valid HTML, but at the expense of flexibility. Thanks for taking the time to provide feedback. |
Using your idea of split button, I made an option with multiple href, and still maintain "showing" the dropdown when clicking on the main input area, which means I was incorrect on my third assumption above: https://jsfiddle.net/jwh02qd3/ Looks ugly, but just going for proof of functionality, and the visuals can be cleaned up. That was a good idea, thanks. https://jsfiddle.net/bphsj5ar/ uses |
About 1. - Sorry to say this, but nested About 2. - Using I can't really argue about why or how About the data attribute, I think that could be some realistic option to disable the preventing behaviour in case it turns out to be a problem. It's indeed a bit awkward but to handle edge cases, maybe we should consider this, as this could be done without breaking things, while allowing more flexibility. |
I have dropdowns that also have links inside them (the links changed based on what is selected inside the dropdown)
This allows links to be clickable within a dropdown toggle to avoid problems like this:
https://jsfiddle.net/jr3eb15g/
I'm not sure why you'd want to avoid the behavior of having links not work inside of the dropdowns?
closes #34400