diff --git a/demo/documentation/components/popconfirm/enUS/customAction.md b/demo/documentation/components/popconfirm/enUS/customAction.md index 5c914a2ce..614cdad75 100644 --- a/demo/documentation/components/popconfirm/enUS/customAction.md +++ b/demo/documentation/components/popconfirm/enUS/customAction.md @@ -1,6 +1,6 @@ # Custom Action ```html - + diff --git a/packages/common/Popover/src/activatorMixin.js b/packages/common/Popover/src/activatorMixin.js index 1d9cce54d..47a714d3e 100644 --- a/packages/common/Popover/src/activatorMixin.js +++ b/packages/common/Popover/src/activatorMixin.js @@ -133,16 +133,44 @@ export default { registerListeners () { const el = this.$el if (el) { - el.removeEventListener('click', this.handleClick) - el.removeEventListener('mouseenter', this.handleMouseEnter) - el.removeEventListener('mouseleave', this.handleMouseLeave) + if (!el['@n-popover-context']) el['@n-popover-context'] = {} + const elContext = el['@n-popover-context'] if (this.triggeredByClick) { - /// console.log('register click') + if (!(elContext.handleClick === this.handleClick)) { + el.removeEventListener('click', elContext.handleClick) + el.addEventListener('click', this.handleClick) + elContext.handleClick = this.handleClick + } + if (elContext.handleMouseEnter) { + el.removeEventListener('mouseenter', elContext.handleMouseEnter) + el.removeEventListener('mouseenter', this.handleMouseEnter) + elContext.handleMouseEnter = null + } + if (elContext.handleMouseLeave) { + el.removeEventListener('mouseenter', elContext.handleMouseLeave) + el.removeEventListener('mouseleave', this.handleMouseLeave) + elContext.handleMouseLeave = null + } + // console.log('register click') + // debugger el.addEventListener('click', this.handleClick) } else if (this.triggeredByHover) { // console.log('register hover') - el.addEventListener('mouseenter', this.handleMouseEnter) - el.addEventListener('mouseleave', this.handleMouseLeave) + if (!(elContext.handleMouseLeave === this.handleMouseLeave)) { + el.removeEventListener('mouseleave', elContext.handleMouseLeave) + el.addEventListener('mouseleave', this.handleMouseLeave) + elContext.handleMouseLeave = this.handleMouseLeave + } + if (!(elContext.handleMouseEnter === this.handleMouseEnter)) { + el.removeEventListener('mouseenter', elContext.handleMouseEnter) + el.addEventListener('mouseenter', this.handleMouseEnter) + elContext.handleMouseEnter = this.handleMouseEnter + } + if (elContext.handleClick) { + el.removeEventListener('click', elContext.handleMouseEnter) + el.removeEventListener('click', this.handleMouseEnter) + elContext.handleMouseEnter = null + } } } } diff --git a/packages/common/Popover/src/main.js b/packages/common/Popover/src/main.js index c7ba39ee9..9c4755624 100644 --- a/packages/common/Popover/src/main.js +++ b/packages/common/Popover/src/main.js @@ -66,6 +66,12 @@ export default { const slots = context.scopedSlots const defaultSlot = slots.default && slots.default() const activatorSlot = slots.activator && slots.activator() + let activatorVNode = activatorSlot[0] + if (!activatorVNode.tag) { + activatorVNode = h('span', { + staticClass: 'n-popover-text-wrapper' + }, [activatorVNode]) + } const id = genId() const props = context.props const listeners = context.listeners @@ -77,7 +83,7 @@ export default { controller, id } - }, [activatorSlot[0]]), + }, [activatorVNode]), h(NBasePortal, {}, [ h(NPopoverContent, { props: {