Bootstrap dropdown calls stopPropagation unconditionally
See original GitHub issueA Bootstrap dropdown element, when first clicked, attaches a click
handler to the element which calls event.stopPropagation()
, thus breaking any handlers that were attached to ancestor elements such as the document.
Demonstration at http://jsbin.com/lapanag/1/edit?html,output which shows the problem.
Is there a reason why this is done? It seems that it will always break anyone who has, for example, a click handler on the document body
. (Many frameworks do this, Meteor among them.) I assume there are compatibility reasons for it or similar?
This is mostly a duplicate of #17008, which was closed because bootstrap development moved from v3 to v4. The design bug is (as you can see from the demo above) still present in v4, I think.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:8
- Comments:9 (4 by maintainers)
Top Results From Across the Web
stopPropagation prevents bootstrap dropdown - Stack Overflow
In your click events, you need to determine when the propagation should stop. Below this is done by sniffing the target element as...
Read more >Dropdowns - Bootstrap
Dropdowns are toggleable, contextual overlays for displaying lists of links and more. They're made interactive with the included Bootstrap dropdown ...
Read more >How to avoid dropdown menu to close menu items on clicking ...
The default behavior of a dropdown menu is to close the menu list items when clicked inside. In this article, We will use...
Read more >Dropdown not usable by events - Material Design for Bootstrap
Expected behavior - open Dropdown by click on another element. I'm trying to open a dropdown by clicking on an input-field. Based on...
Read more >Bootstrap JS Dropdown Reference - W3Schools
Note: The data-toggle="dropdown" attribute is required regardless of whether you call the dropdown() method. Dropdown Options. None. Dropdown Methods. The ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
One of the consequences of this issue also comes up when you build your own menu and Bootstrap Dropdown stops propagation, which prevents the custom menu from closing.
I know it’s not a solution, more a quick fix. But it works: Catch the show/hide event and propagate a new custom event, the first time the counter increased twice because ‘native’ click event works once.
http://jsbin.com/jiyuhihuya/1/edit?html,output