From 90051339fe980e9c232cf5531309c5c3b75b1b99 Mon Sep 17 00:00:00 2001 From: Gerald Monaco Date: Fri, 23 Apr 2021 01:55:46 +0000 Subject: [PATCH] Workaround for discrete passive effects change --- .../link-ref/pages/click-away-race-condition.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/integration/link-ref/pages/click-away-race-condition.js b/test/integration/link-ref/pages/click-away-race-condition.js index a5b0d51e281be..b70cdd67a35d1 100644 --- a/test/integration/link-ref/pages/click-away-race-condition.js +++ b/test/integration/link-ref/pages/click-away-race-condition.js @@ -13,9 +13,15 @@ const useClickAway = (ref, onClickAway) => { el && !el.contains(event.target) && onClickAway(event) } - document.addEventListener('click', handler) + let timeoutID = setTimeout(() => { + timeoutID = null + document.addEventListener('click', handler) + }, 0) return () => { + if (timeoutID != null) { + clearTimeout(timeoutID) + } document.removeEventListener('click', handler) } }, [onClickAway, ref])