diff --git a/src/mixins/dropdown.js b/src/mixins/dropdown.js index c9fced295c1..154799be3af 100644 --- a/src/mixins/dropdown.js +++ b/src/mixins/dropdown.js @@ -172,6 +172,7 @@ export default { created() { // Create private non-reactive props this.$_popper = null + this.$_hideTimeout = null }, /* istanbul ignore next */ deactivated() /* istanbul ignore next: not easy to test */ { @@ -184,6 +185,7 @@ export default { this.visible = false this.whileOpenListen(false) this.destroyPopper() + this.clearHideTimeout() }, methods: { // Event emitter @@ -249,6 +251,10 @@ export default { this.$_popper.scheduleUpdate() } catch {} }, + clearHideTimeout() { + clearTimeout(this.$_hideTimeout) + this.$_hideTimeout = null + }, getPopperConfig() { let placement = PLACEMENT_BOTTOM_START if (this.dropup) { @@ -288,8 +294,8 @@ export default { this.visible = false } }, + // Public method to show dropdown show() { - // Public method to show dropdown if (this.disabled) { return } @@ -299,10 +305,10 @@ export default { this.visible = true }) }, + // Public method to hide dropdown hide(refocus = false) { - // Public method to hide dropdown + /* istanbul ignore next */ if (this.disabled) { - /* istanbul ignore next */ return } this.visible = false @@ -386,7 +392,8 @@ export default { hideHandler(evt) { const { target } = evt if (this.visible && !contains(this.$refs.menu, target) && !contains(this.toggler, target)) { - this.hide() + this.clearHideTimeout() + this.$_hideTimeout = setTimeout(() => this.hide(), this.inNavbar ? 300 : 0) } }, // Document click-out listener