Skip to content

Commit d067119

Browse files
committed
feat(popper): config opt to manage submenu auto close bhv
1 parent 48268ea commit d067119

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

packages/floating-vue/src/components/Popper.ts

+13-6
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,11 @@ const createPopper = () => defineComponent({
277277
type: Number,
278278
default: defaultPropFactory('disposeTimeout'),
279279
},
280+
281+
autoCloseTimeout: {
282+
type: Number,
283+
default: defaultPropFactory('autoCloseTimeout'),
284+
},
280285
},
281286

282287
emits: {
@@ -467,12 +472,14 @@ const createPopper = () => defineComponent({
467472
if (this.parentPopper) {
468473
this.parentPopper.lockedChild = this
469474
clearTimeout(this.parentPopper.lockedChildTimer)
470-
// this.parentPopper.lockedChildTimer = setTimeout(() => {
471-
// if (this.parentPopper.lockedChild !== this) {
472-
// this.parentPopper.lockedChild.hide({ skipDelay })
473-
// this.parentPopper.lockedChild = null
474-
// }
475-
// }, 1000)
475+
if (this.autoCloseTimeout > 0) {
476+
this.parentPopper.lockedChildTimer = setTimeout(() => {
477+
if (this.parentPopper.lockedChild === this) {
478+
this.parentPopper.lockedChild.hide({ skipDelay })
479+
this.parentPopper.lockedChild = null
480+
}
481+
}, this.autoCloseTimeout)
482+
}
476483
}
477484
return
478485
}

packages/floating-vue/src/config.ts

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ export const config: FloatingVueConfig = {
3131
arrowPadding: 0,
3232
// Compute arrow overflow (useful to hide it)
3333
arrowOverflow: true,
34+
// Timeout that will trigger the closing of parent popper in (ms - 0 means disabled)
35+
autoCloseTimeout: 1000,
3436
/**
3537
* By default, compute autohide on 'click'.
3638
*/

0 commit comments

Comments
 (0)