Skip to content

Commit 01ef6f8

Browse files
committed
feat: add aiming expiration delay
1 parent f06366c commit 01ef6f8

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

packages/docs/src/guide/component.md

+2
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ Floating Vue will automatically fix the [diagonal submenu problem](https://www.g
278278
<img alt="popper aim debug example" src="./popper-aim.png" class="border border-gray-200 rounded">
279279
</div>
280280

281+
After a one second delay, the lock applied because of aiming will expire.
282+
281283
## Disable popper
282284

283285
Disabling a popper will prevent it from being shown.

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

+11
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,10 @@ export default () => ({
392392

393393
this.$_pendingHide = false
394394
if (force || !this.disabled) {
395+
if (this.parentPopper?.lockedChild === this) {
396+
this.parentPopper.lockedChild = null
397+
}
398+
395399
this.$_scheduleShow(event, skipDelay)
396400
this.$emit('show')
397401

@@ -417,6 +421,13 @@ export default () => ({
417421
if (this.$_isAimingPopper()) {
418422
if (this.parentPopper) {
419423
this.parentPopper.lockedChild = this
424+
clearTimeout(this.parentPopper.lockedChildTimer)
425+
this.parentPopper.lockedChildTimer = setTimeout(() => {
426+
if (this.parentPopper.lockedChild === this) {
427+
this.parentPopper.lockedChild.hide({ skipDelay })
428+
this.parentPopper.lockedChild = null
429+
}
430+
}, 1000)
420431
}
421432
return
422433
}

0 commit comments

Comments
 (0)