From 48268ead711950fa317daab04a27b0921b14d547 Mon Sep 17 00:00:00 2001 From: Moritz Gleissner Date: Thu, 26 Sep 2024 17:38:30 +0200 Subject: [PATCH 1/2] fix(popper): menu closing on hover over item --- packages/floating-vue/src/components/Popper.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/floating-vue/src/components/Popper.ts b/packages/floating-vue/src/components/Popper.ts index ef714159..1211039c 100644 --- a/packages/floating-vue/src/components/Popper.ts +++ b/packages/floating-vue/src/components/Popper.ts @@ -467,12 +467,12 @@ const createPopper = () => defineComponent({ if (this.parentPopper) { this.parentPopper.lockedChild = this clearTimeout(this.parentPopper.lockedChildTimer) - this.parentPopper.lockedChildTimer = setTimeout(() => { - if (this.parentPopper.lockedChild === this) { - this.parentPopper.lockedChild.hide({ skipDelay }) - this.parentPopper.lockedChild = null - } - }, 1000) + // this.parentPopper.lockedChildTimer = setTimeout(() => { + // if (this.parentPopper.lockedChild !== this) { + // this.parentPopper.lockedChild.hide({ skipDelay }) + // this.parentPopper.lockedChild = null + // } + // }, 1000) } return } From d06711989d1ac0da90df90fa71991f4a64bb13a9 Mon Sep 17 00:00:00 2001 From: Moritz Gleissner Date: Thu, 26 Sep 2024 19:10:35 +0200 Subject: [PATCH 2/2] feat(popper): config opt to manage submenu auto close bhv --- .../floating-vue/src/components/Popper.ts | 19 +++++++++++++------ packages/floating-vue/src/config.ts | 2 ++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/packages/floating-vue/src/components/Popper.ts b/packages/floating-vue/src/components/Popper.ts index 1211039c..fe4416c1 100644 --- a/packages/floating-vue/src/components/Popper.ts +++ b/packages/floating-vue/src/components/Popper.ts @@ -277,6 +277,11 @@ const createPopper = () => defineComponent({ type: Number, default: defaultPropFactory('disposeTimeout'), }, + + autoCloseTimeout: { + type: Number, + default: defaultPropFactory('autoCloseTimeout'), + }, }, emits: { @@ -467,12 +472,14 @@ const createPopper = () => defineComponent({ if (this.parentPopper) { this.parentPopper.lockedChild = this clearTimeout(this.parentPopper.lockedChildTimer) - // this.parentPopper.lockedChildTimer = setTimeout(() => { - // if (this.parentPopper.lockedChild !== this) { - // this.parentPopper.lockedChild.hide({ skipDelay }) - // this.parentPopper.lockedChild = null - // } - // }, 1000) + if (this.autoCloseTimeout > 0) { + this.parentPopper.lockedChildTimer = setTimeout(() => { + if (this.parentPopper.lockedChild === this) { + this.parentPopper.lockedChild.hide({ skipDelay }) + this.parentPopper.lockedChild = null + } + }, this.autoCloseTimeout) + } } return } diff --git a/packages/floating-vue/src/config.ts b/packages/floating-vue/src/config.ts index 30a3ffa7..f4f0eaaf 100644 --- a/packages/floating-vue/src/config.ts +++ b/packages/floating-vue/src/config.ts @@ -31,6 +31,8 @@ export const config: FloatingVueConfig = { arrowPadding: 0, // Compute arrow overflow (useful to hide it) arrowOverflow: true, + // Timeout that will trigger the closing of parent popper in (ms - 0 means disabled) + autoCloseTimeout: 1000, /** * By default, compute autohide on 'click'. */