🌐 AI搜索 & 代理 主页
Skip to content

Commit ebe54ea

Browse files
committed
Update dropdown.js
1 parent 88cd1c4 commit ebe54ea

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/mixins/dropdown.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ export default {
172172
created() {
173173
// Create private non-reactive props
174174
this.$_popper = null
175+
this.$_hideTimeout = null
175176
},
176177
/* istanbul ignore next */
177178
deactivated() /* istanbul ignore next: not easy to test */ {
@@ -184,6 +185,7 @@ export default {
184185
this.visible = false
185186
this.whileOpenListen(false)
186187
this.destroyPopper()
188+
this.clearHideTimeout()
187189
},
188190
methods: {
189191
// Event emitter
@@ -249,6 +251,10 @@ export default {
249251
this.$_popper.scheduleUpdate()
250252
} catch {}
251253
},
254+
clearHideTimeout() {
255+
clearTimeout(this.$_hideTimeout)
256+
this.$_hideTimeout = null
257+
},
252258
getPopperConfig() {
253259
let placement = PLACEMENT_BOTTOM_START
254260
if (this.dropup) {
@@ -386,7 +392,8 @@ export default {
386392
hideHandler(evt) {
387393
const { target } = evt
388394
if (this.visible && !contains(this.$refs.menu, target) && !contains(this.toggler, target)) {
389-
this.hide()
395+
this.clearHideTimeout()
396+
this.$_hideTimeout = setTimeout(() => this.hide(), this.inNavbar ? 300 : 0)
390397
}
391398
},
392399
// Document click-out listener
@@ -395,9 +402,7 @@ export default {
395402
},
396403
// Document focus-in listener
397404
focusInHandler(evt) {
398-
setTimeout(() => {
399-
this.hideHandler(evt)
400-
}, this.inNavbar ? 300 : 0)
405+
this.hideHandler(evt)
401406
},
402407
// Keyboard nav
403408
focusNext(evt, up) {

0 commit comments

Comments
 (0)