Skip to content

Commit

Permalink
check mouseDownTimeout timer before calling clearTimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
shc023 committed Jul 31, 2021
1 parent 55ed22f commit b2de5d2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ export function generateTrigger(
componentWillUnmount() {
this.clearDelayTimer();
this.clearOutsideHandler();
clearTimeout(this.mouseDownTimeout);
this.clearMouseDownTimer();
raf.cancel(this.attachId);
}

Expand Down Expand Up @@ -389,6 +389,7 @@ export function generateTrigger(
clearTimeout(this.mouseDownTimeout);
this.mouseDownTimeout = window.setTimeout(() => {
this.hasPopupMouseDown = false;
this.clearMouseDownTimer();
}, 0);

if (this.context) {
Expand Down Expand Up @@ -666,6 +667,13 @@ export function generateTrigger(
}
}

clearMouseDownTimer() {
if (this.mouseDownTimeout) {
clearTimeout(this.mouseDownTimeout);
this.mouseDownTimeout = null;
}
}

clearOutsideHandler() {
if (this.clickOutsideHandler) {
this.clickOutsideHandler.remove();
Expand Down

0 comments on commit b2de5d2

Please sign in to comment.