From d30032b9121074f8e01ee1cd4ba205588b8df92e Mon Sep 17 00:00:00 2001 From: melloware Date: Fri, 10 Jan 2025 08:43:46 -0500 Subject: [PATCH] Fix #6008: Tooltip allow onBeforeHide to prevent hiding --- components/lib/tooltip/Tooltip.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/components/lib/tooltip/Tooltip.js b/components/lib/tooltip/Tooltip.js index 654d3d5e3a..2eba0bf557 100644 --- a/components/lib/tooltip/Tooltip.js +++ b/components/lib/tooltip/Tooltip.js @@ -207,8 +207,10 @@ export const Tooltip = React.memo( clearTimeouts(); + let success = true; + if (visibleState) { - const success = sendCallback(props.onBeforeHide, { originalEvent: e, target: currentTargetRef.current }); + success = sendCallback(props.onBeforeHide, { originalEvent: e, target: currentTargetRef.current }); if (success) { applyDelay('hideDelay', () => { @@ -225,7 +227,9 @@ export const Tooltip = React.memo( } // handles the case when visibleState change from mouseenter was queued and mouseleave handler was called earlier than queued re-render - setVisibleState(false); + if (success) { + setVisibleState(false); + } }; const align = (target, coordinate, position) => {