Stopping the event propagation prevent the user to watch for the event at an higher level. If it was needed to prevent a duplicate behavior in a component, others methods should be used like debouncing the event.
Changes:
- Remove `stopPropagation` and `stopImmediatePropagation` from everywhere we do not want to cancel the event (AccordionMenu, Drilldown, DropdownMenu, Tabs, Tooltip).
- Update `DropdownMenu._removeBodyHandler` to also ignore click events on the element itself.
Others changes:
- Clean up `DropdownMenu._events` a bit.
- Add explainaitions where `stopPropagation` is still used (Triggers).
See https://github.com/zurb/foundation-sites/issues/11457
if (preventDefault) {
e.preventDefault();
}
- e.stopImmediatePropagation();
}
});
});//.attr('tabindex', 0);
$elem.off('click.zf.drilldown')
.on('click.zf.drilldown', function(e){
if($(e.target).parentsUntil('ul', 'li').hasClass('is-drilldown-submenu-parent')){
- e.stopImmediatePropagation();
e.preventDefault();
}
if (preventDefault) {
e.preventDefault();
}
- e.stopImmediatePropagation();
}
});
}); // end keyboardAccess
$elem.off('click.zf.drilldown');
$elem.children('.js-drilldown-back')
.on('click.zf.drilldown', function(e){
- e.stopImmediatePropagation();
// console.log('mouseup on back');
_this._hide($elem);
this.$menuItems.not('.is-drilldown-submenu-parent')
.off('click.zf.drilldown')
.on('click.zf.drilldown', function(e){
- // e.stopImmediatePropagation();
setTimeout(function(){
_this._hideAll();
}, 0);
if (hasSub) {
if (hasClicked) {
- if (!_this.options.closeOnClick || (!_this.options.clickOpen && !hasTouch) || (_this.options.forceFollow && hasTouch)) { return; }
- else {
- e.stopImmediatePropagation();
- e.preventDefault();
- _this._hide($elem);
+ if (!_this.options.closeOnClick
+ || (!_this.options.clickOpen && !hasTouch)
+ || (_this.options.forceFollow && hasTouch)) {
+ return;
}
- } else {
e.preventDefault();
- e.stopImmediatePropagation();
+ _this._hide($elem);
+ }
+ else {
+ e.preventDefault();
_this._show($sub);
$elem.add($elem.parentsUntil(_this.$element, `.${parClass}`)).attr('data-is-click', true);
}
const $body = $(document.body);
this._removeBodyHandler();
$body.on('click.zf.dropdownMenu tap.zf.dropdownMenu', (e) => {
- var $link = this.$element.find(e.target);
- if ($link.length) return;
+ var isItself = this.$element.andSelf().find(e.target).length;
+ if (isItself) return;
this._hide();
this._removeBodyHandler();
.off('click.zf.tabs')
.on('click.zf.tabs', `.${this.options.linkClass}`, function(e){
e.preventDefault();
- e.stopPropagation();
_this._handleTabChange($(this));
});
}
if (this.options.clickOpen) {
this.$element.on('mousedown.zf.tooltip', function(e) {
- e.stopImmediatePropagation();
if (_this.isClick) {
//_this.hide();
// _this.isClick = false;
});
} else {
this.$element.on('mousedown.zf.tooltip', function(e) {
- e.stopImmediatePropagation();
_this.isClick = true;
});
}
}
},
closeableListener: function(e) {
- e.stopPropagation();
let animation = $(this).data('closable');
+ // Only close the first closable element. See https://git.io/zf-7833
+ e.stopPropagation();
+
if(animation !== ''){
Motion.animateOut($(this), animation, function() {
$(this).trigger('closed.zf');