From 368e2ba9efc89e7d9027e13da8e3a603cab1c1de Mon Sep 17 00:00:00 2001 From: Tom Butcher Date: Fri, 21 Aug 2026 11:09:27 +0100 Subject: [PATCH] Refactor Tooltip Component to Improve Hover Target Management - Introduced a variable for hovered targets in the Tooltip component to enhance clarity and maintainability of the hover state management. - Updated the cleanup logic to directly reference the hovered targets variable, streamlining the event listener removal process. --- src/components/Dashboard/common/Tooltip.jsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/Dashboard/common/Tooltip.jsx b/src/components/Dashboard/common/Tooltip.jsx index f9a10d9d..e435d3ce 100644 --- a/src/components/Dashboard/common/Tooltip.jsx +++ b/src/components/Dashboard/common/Tooltip.jsx @@ -55,6 +55,8 @@ const Tooltip = ({ children, title, content, listenParents = 0 }) => { const span = spanRef.current if (!span || listenParents < 1) return + const hoveredTargets = hoveredTargetsRef.current + const handleEnter = (event) => onMouseEnterRef.current(event) const handleLeave = (event) => onMouseLeaveRef.current(event) @@ -75,7 +77,7 @@ const Tooltip = ({ children, title, content, listenParents = 0 }) => { parent.removeEventListener('mouseenter', handleEnter) parent.removeEventListener('mouseleave', handleLeave) }) - hoveredTargetsRef.current.clear() + hoveredTargets.clear() } }, [listenParents])