Skip to content

fix(b-dropdown): click handling on close (closes #5982) #6009

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Nov 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/mixins/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */ {
Expand All @@ -184,6 +185,7 @@ export default {
this.visible = false
this.whileOpenListen(false)
this.destroyPopper()
this.clearHideTimeout()
},
methods: {
// Event emitter
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -288,8 +294,8 @@ export default {
this.visible = false
}
},
// Public method to show dropdown
show() {
// Public method to show dropdown
if (this.disabled) {
return
}
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down