From 01ef6f86aadc43488ade03cffd2158f2825cb416 Mon Sep 17 00:00:00 2001 From: Guillaume Chau Date: Wed, 23 Mar 2022 12:43:48 +0100 Subject: [PATCH] feat: add aiming expiration delay --- packages/docs/src/guide/component.md | 2 ++ packages/floating-vue/src/components/Popper.ts | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/packages/docs/src/guide/component.md b/packages/docs/src/guide/component.md index 53b00219..f464b8b1 100644 --- a/packages/docs/src/guide/component.md +++ b/packages/docs/src/guide/component.md @@ -278,6 +278,8 @@ Floating Vue will automatically fix the [diagonal submenu problem](https://www.g popper aim debug example +After a one second delay, the lock applied because of aiming will expire. + ## Disable popper Disabling a popper will prevent it from being shown. diff --git a/packages/floating-vue/src/components/Popper.ts b/packages/floating-vue/src/components/Popper.ts index 90c662bd..9786d714 100644 --- a/packages/floating-vue/src/components/Popper.ts +++ b/packages/floating-vue/src/components/Popper.ts @@ -392,6 +392,10 @@ export default () => ({ this.$_pendingHide = false if (force || !this.disabled) { + if (this.parentPopper?.lockedChild === this) { + this.parentPopper.lockedChild = null + } + this.$_scheduleShow(event, skipDelay) this.$emit('show') @@ -417,6 +421,13 @@ export default () => ({ if (this.$_isAimingPopper()) { 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) } return }