question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bootstrap dropdown calls stopPropagation unconditionally

See original GitHub issue

A 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:closed
  • Created 6 years ago
  • Reactions:8
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
o-alquimistacommented, Jan 10, 2020

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.

Peek 10-01-2020 17-57

1reaction
shenroncommented, Jul 24, 2018

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found