diff --git a/src/components/modal/modal.js b/src/components/modal/modal.js index fd72a0353c7..90dcb40f529 100644 --- a/src/components/modal/modal.js +++ b/src/components/modal/modal.js @@ -588,13 +588,12 @@ export const BModal = /*#__PURE__*/ Vue.extend({ this.emitEvent(this.buildEvent(EVENT_NAME_HIDDEN)) }) }, - // Event emitter - emitEvent(bvModalEvt) { - const type = bvModalEvt.type - // We emit on root first incase a global listener wants to cancel + emitEvent(bvEvent) { + const { type } = bvEvent + // We emit on `$root` first in case a global listener wants to cancel // the event first before the instance emits its event - this.emitOnRoot(getRootEventName(NAME_MODAL, type), bvModalEvt, bvModalEvt.componentId) - this.$emit(type, bvModalEvt) + this.emitOnRoot(getRootEventName(NAME_MODAL, type), bvEvent, bvEvent.componentId) + this.$emit(type, bvEvent) }, // UI event handlers onDialogMousedown() { diff --git a/src/components/tooltip/helpers/bv-tooltip.js b/src/components/tooltip/helpers/bv-tooltip.js index a2a9c99e458..2fe03791d26 100644 --- a/src/components/tooltip/helpers/bv-tooltip.js +++ b/src/components/tooltip/helpers/bv-tooltip.js @@ -63,6 +63,7 @@ import { toInteger } from '../../../utils/number' import { keys } from '../../../utils/object' import { warn } from '../../../utils/warn' import { BvEvent } from '../../../utils/bv-event.class' +import { listenOnRootMixin } from '../../../mixins/listen-on-root' import { BVTooltipTemplate } from './bv-tooltip-template' // --- Constants --- @@ -138,6 +139,7 @@ const templateData = { // @vue/component export const BVTooltip = /*#__PURE__*/ Vue.extend({ name: NAME_TOOLTIP_HELPER, + mixins: [listenOnRootMixin], data() { return { // BTooltip/BPopover/VBTooltip/VBPopover will update this data @@ -681,14 +683,9 @@ export const BVTooltip = /*#__PURE__*/ Vue.extend({ }) }, emitEvent(bvEvent) { - // Emits a BvEvent on $root and this instance - const eventName = bvEvent.type - const $root = this.$root - if ($root && $root.$emit) { - // Emit an event on $root - $root.$emit(getRootEventName(this.templateType, eventName), bvEvent) - } - this.$emit(eventName, bvEvent) + const { type } = bvEvent + this.emitOnRoot(getRootEventName(this.templateType, type), bvEvent) + this.$emit(type, bvEvent) }, // --- Event handler setup methods --- listen() { diff --git a/src/mixins/dropdown.js b/src/mixins/dropdown.js index 865dd278f8d..5d3ab618d34 100644 --- a/src/mixins/dropdown.js +++ b/src/mixins/dropdown.js @@ -184,8 +184,8 @@ export const dropdownMixin = Vue.extend({ // Event emitter emitEvent(bvEvent) { const { type } = bvEvent + this.emitOnRoot(getRootEventName(NAME_DROPDOWN, type), bvEvent) this.$emit(type, bvEvent) - this.emitOnRoot(getRootEventName(NAME_DROPDOWN, type)) }, showMenu() { if (this.disabled) {