Skip to content

Commit c9ee452

Browse files
committed
fix(b-dropdown): root events
1 parent 9722376 commit c9ee452

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

src/components/modal/modal.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -588,13 +588,12 @@ export const BModal = /*#__PURE__*/ Vue.extend({
588588
this.emitEvent(this.buildEvent(EVENT_NAME_HIDDEN))
589589
})
590590
},
591-
// Event emitter
592-
emitEvent(bvModalEvt) {
593-
const type = bvModalEvt.type
594-
// We emit on root first incase a global listener wants to cancel
591+
emitEvent(bvEvent) {
592+
const { type } = bvEvent
593+
// We emit on `$root` first in case a global listener wants to cancel
595594
// the event first before the instance emits its event
596-
this.emitOnRoot(getRootEventName(NAME_MODAL, type), bvModalEvt, bvModalEvt.componentId)
597-
this.$emit(type, bvModalEvt)
595+
this.emitOnRoot(getRootEventName(NAME_MODAL, type), bvEvent, bvEvent.componentId)
596+
this.$emit(type, bvEvent)
598597
},
599598
// UI event handlers
600599
onDialogMousedown() {

src/components/tooltip/helpers/bv-tooltip.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ import { toInteger } from '../../../utils/number'
6363
import { keys } from '../../../utils/object'
6464
import { warn } from '../../../utils/warn'
6565
import { BvEvent } from '../../../utils/bv-event.class'
66+
import { listenOnRootMixin } from '../../../mixins/listen-on-root'
6667
import { BVTooltipTemplate } from './bv-tooltip-template'
6768

6869
// --- Constants ---
@@ -138,6 +139,7 @@ const templateData = {
138139
// @vue/component
139140
export const BVTooltip = /*#__PURE__*/ Vue.extend({
140141
name: NAME_TOOLTIP_HELPER,
142+
mixins: [listenOnRootMixin],
141143
data() {
142144
return {
143145
// BTooltip/BPopover/VBTooltip/VBPopover will update this data
@@ -681,14 +683,9 @@ export const BVTooltip = /*#__PURE__*/ Vue.extend({
681683
})
682684
},
683685
emitEvent(bvEvent) {
684-
// Emits a BvEvent on $root and this instance
685-
const eventName = bvEvent.type
686-
const $root = this.$root
687-
if ($root && $root.$emit) {
688-
// Emit an event on $root
689-
$root.$emit(getRootEventName(this.templateType, eventName), bvEvent)
690-
}
691-
this.$emit(eventName, bvEvent)
686+
const { type } = bvEvent
687+
this.emitOnRoot(getRootEventName(this.templateType, type), bvEvent)
688+
this.$emit(type, bvEvent)
692689
},
693690
// --- Event handler setup methods ---
694691
listen() {

src/mixins/dropdown.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ export const dropdownMixin = Vue.extend({
184184
// Event emitter
185185
emitEvent(bvEvent) {
186186
const { type } = bvEvent
187+
this.emitOnRoot(getRootEventName(NAME_DROPDOWN, type), bvEvent)
187188
this.$emit(type, bvEvent)
188-
this.emitOnRoot(getRootEventName(NAME_DROPDOWN, type))
189189
},
190190
showMenu() {
191191
if (this.disabled) {

0 commit comments

Comments
 (0)