Commit 6d2f68b2 authored by cinwell.li's avatar cinwell.li Committed by baiyaaaaa

Popup: prevent click event bubbles, fixed #1677 (#1754)

parent 5e692418
import PopperJS from './popper'; import PopperJS from './popper';
import { PopupManager } from 'vue-popup'; import { PopupManager } from 'vue-popup';
const stop = e => e.stopPropagation();
/** /**
* @param {HTMLElement} [reference=$refs.reference] - The reference element used to position the popper. * @param {HTMLElement} [reference=$refs.reference] - The reference element used to position the popper.
* @param {HTMLElement} [popper=$refs.popper] - The HTML element used as popper, or a configuration used to generate the popper. * @param {HTMLElement} [popper=$refs.popper] - The HTML element used as popper, or a configuration used to generate the popper.
...@@ -93,6 +95,7 @@ export default { ...@@ -93,6 +95,7 @@ export default {
this.$nextTick(this.updatePopper); this.$nextTick(this.updatePopper);
}); });
this.popperJS._popper.style.zIndex = PopupManager.nextZIndex(); this.popperJS._popper.style.zIndex = PopupManager.nextZIndex();
this.popperElm.addEventListener('click', stop);
}, },
updatePopper() { updatePopper() {
...@@ -149,9 +152,10 @@ export default { ...@@ -149,9 +152,10 @@ export default {
beforeDestroy() { beforeDestroy() {
this.doDestroy(); this.doDestroy();
this.popperElm && if (this.popperElm && this.popperElm.parentNode === document.body) {
this.popperElm.parentNode === document.body && this.popperElm.removeEventListener('click', stop);
document.body.removeChild(this.popperElm); document.body.removeChild(this.popperElm);
}
}, },
// call destroy in keep-alive mode // call destroy in keep-alive mode
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment