From b2de5d2b453e4dbebdab010cbebc5cca1e32f025 Mon Sep 17 00:00:00 2001 From: Scott Chen Date: Fri, 30 Jul 2021 17:21:17 -0700 Subject: [PATCH] check mouseDownTimeout timer before calling clearTimeout --- src/index.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/index.tsx b/src/index.tsx index bd60336f..4a844fe9 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -262,7 +262,7 @@ export function generateTrigger( componentWillUnmount() { this.clearDelayTimer(); this.clearOutsideHandler(); - clearTimeout(this.mouseDownTimeout); + this.clearMouseDownTimer(); raf.cancel(this.attachId); } @@ -389,6 +389,7 @@ export function generateTrigger( clearTimeout(this.mouseDownTimeout); this.mouseDownTimeout = window.setTimeout(() => { this.hasPopupMouseDown = false; + this.clearMouseDownTimer(); }, 0); if (this.context) { @@ -666,6 +667,13 @@ export function generateTrigger( } } + clearMouseDownTimer() { + if (this.mouseDownTimeout) { + clearTimeout(this.mouseDownTimeout); + this.mouseDownTimeout = null; + } + } + clearOutsideHandler() { if (this.clickOutsideHandler) { this.clickOutsideHandler.remove();