Skip to content

Commit

Permalink
feat: add aiming expiration delay
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum committed Mar 23, 2022
1 parent f06366c commit 01ef6f8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/docs/src/guide/component.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ Floating Vue will automatically fix the [diagonal submenu problem](https://www.g
<img alt="popper aim debug example" src="./popper-aim.png" class="border border-gray-200 rounded">
</div>

After a one second delay, the lock applied because of aiming will expire.

## Disable popper

Disabling a popper will prevent it from being shown.
Expand Down
11 changes: 11 additions & 0 deletions packages/floating-vue/src/components/Popper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand All @@ -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 comment has been minimized.

Copy link
@towry

towry Nov 7, 2023

In the latest code's comment: // Abort if aiming for the popper, so if the aiming current is the popper(which means it should stay open, right, because we just move cursor from the reference to the popper element.? why closing this after one second? (this.parentPopper.lockedChild === this)

Seems change if (this.parentPopper.lockedChild === this) { to if (this.parentPopper.lockedChild !== this) { works fine.

This comment has been minimized.

Copy link
@towry

towry Nov 7, 2023

related issue: #916

This comment has been minimized.

Copy link
@Moerliy

Moerliy Sep 26, 2024

changing this will open up the possibility for .lockedChild to be null or undefined. This will cause an error in line 427

this.parentPopper.lockedChild.hide({ skipDelay })
this.parentPopper.lockedChild = null
}
}, 1000)
}
return
}
Expand Down

0 comments on commit 01ef6f8

Please sign in to comment.