From 0b9a212f33381d07ff67e2453753aaab64cc8041 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 2 Sep 2024 16:04:37 -0700 Subject: [PATCH] Fixed: Links tooltip closing too quickly --- frontend/src/Components/Tooltip/Tooltip.tsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/frontend/src/Components/Tooltip/Tooltip.tsx b/frontend/src/Components/Tooltip/Tooltip.tsx index 35cce5738..c3d955ad2 100644 --- a/frontend/src/Components/Tooltip/Tooltip.tsx +++ b/frontend/src/Components/Tooltip/Tooltip.tsx @@ -65,8 +65,7 @@ function Tooltip(props: TooltipProps) { const handleMouseLeave = useCallback(() => { // Still listen for mouse leave on mobile to allow clicks outside to close the tooltip. - - setTimeout(() => { + closeTimeout.current = window.setTimeout(() => { setIsOpen(false); }, 100); }, [setIsOpen]); @@ -111,18 +110,18 @@ function Tooltip(props: TooltipProps) { ); useEffect(() => { - const currentTimeout = closeTimeout.current; - if (updater.current && isOpen) { updater.current(); } + }); + useEffect(() => { return () => { - if (currentTimeout) { - window.clearTimeout(currentTimeout); + if (closeTimeout.current) { + window.clearTimeout(closeTimeout.current); } }; - }); + }, []); return (