Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: only clear existing timeouts #1060

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions packages/floating-vue/src/components/Popper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,9 @@ const createPopper = () => defineComponent({
if (this.hasPopperShowTriggerHover && this.$_isAimingPopper()) {
if (this.parentPopper) {
this.parentPopper.lockedChild = this
clearTimeout(this.parentPopper.lockedChildTimer)
if (this.parentPopper.lockedChildTimer) {
clearTimeout(this.parentPopper.lockedChildTimer)
}
this.parentPopper.lockedChildTimer = setTimeout(() => {
if (this.parentPopper.lockedChild === this) {
this.parentPopper.lockedChild.hide({ skipDelay })
Expand Down Expand Up @@ -695,7 +697,9 @@ const createPopper = () => defineComponent({
}
this.$_updateParentShownChildren(false)
this.$_hideInProgress = true
clearTimeout(this.$_scheduleTimer)
if (this.$_scheduleTimer) {
clearTimeout(this.$_scheduleTimer)
}

if (this.isShown) {
// eslint-disable-next-line @typescript-eslint/no-this-alias
Expand All @@ -715,8 +719,12 @@ const createPopper = () => defineComponent({
},

async $_applyShow (skipTransition = false) {
clearTimeout(this.$_disposeTimer)
clearTimeout(this.$_scheduleTimer)
if (this.$_disposeTimer) {
clearTimeout(this.$_disposeTimer)
}
if (this.$_scheduleTimer) {
clearTimeout(this.$_scheduleTimer)
}
this.skipTransition = skipTransition

// Already shown
Expand Down Expand Up @@ -798,7 +806,9 @@ const createPopper = () => defineComponent({
this.$_hideInProgress = false
return
}
clearTimeout(this.$_scheduleTimer)
if (this.$_scheduleTimer) {
clearTimeout(this.$_scheduleTimer)
}

// Already hidden
if (!this.isShown) {
Expand Down Expand Up @@ -829,7 +839,9 @@ const createPopper = () => defineComponent({
'data-popper-shown': undefined,
})

clearTimeout(this.$_disposeTimer)
if (this.$_disposeTimer) {
clearTimeout(this.$_disposeTimer)
}
const disposeTime = this.disposeTimeout
if (disposeTime !== null) {
this.$_disposeTimer = setTimeout(() => {
Expand Down