MDL-83223 core: Use capture with addEventListener to intercept events
The issue is that Bootstrap’s dropdown component likely stops event propagation after the first click to manage its own dropdown behavior. This prevents your click event handler from running on subsequent clicks. To fix this, we can handle the event before Bootstrap’s code stops the propagation by using capture option with addEventListener.
This commit is contained in:
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -326,12 +326,13 @@ define(['jquery', 'core/str', 'core/custom_interaction_events'],
|
||||
}.bind(this));
|
||||
|
||||
// Close the popover if any other part of the page is clicked.
|
||||
$('html').click(function(e) {
|
||||
var target = $(e.target);
|
||||
document.addEventListener('click', (e) => {
|
||||
const target = e.target;
|
||||
// Check if the click is outside the root element.
|
||||
if (!this.root.is(target) && !this.root.has(target).length) {
|
||||
this.closeMenu();
|
||||
}
|
||||
}.bind(this));
|
||||
}, true); // `true` makes it a capture phase event listener.
|
||||
|
||||
customEvents.define(this.getContentContainer(), [
|
||||
customEvents.events.scrollBottom
|
||||
|
||||
Reference in New Issue
Block a user