From 65beec5a6f1ae5fade6ca7fd7dd0f99709fed20e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Thu, 14 Nov 2024 10:21:38 +0100 Subject: [PATCH] Control tooltip to avoid it showing when closing popover --- .../components/connections-filter-popover.tsx | 123 ++++++++++-------- 1 file changed, 70 insertions(+), 53 deletions(-) diff --git a/packages/compass-sidebar/src/components/connections-filter-popover.tsx b/packages/compass-sidebar/src/components/connections-filter-popover.tsx index 404c6815041..4cf936dadf3 100644 --- a/packages/compass-sidebar/src/components/connections-filter-popover.tsx +++ b/packages/compass-sidebar/src/components/connections-filter-popover.tsx @@ -1,4 +1,4 @@ -import React, { useCallback, type PropsWithChildren } from 'react'; +import React, { useCallback, useState, type PropsWithChildren } from 'react'; import { css, @@ -67,58 +67,75 @@ export default function ConnectionsFilterPopover({ // Add future filters to the boolean below const isActivated = filter.excludeInactive; + // Manually handling the tooltip state instead of supplying a trigger + // we do this to avoid the tooltip from rendering when the popover is open + // and when the IconButton regains focus as the + const [isTooltipOpen, setTooltipOpen] = useState(false); + const handleButtonMouseEnter = useCallback( + () => setTooltipOpen(true), + [setTooltipOpen] + ); + const handleButtonMouseLeave = useCallback( + () => setTooltipOpen(false), + [setTooltipOpen] + ); + return ( - ( - <> - } - > - - {isActivated && ( - - - - )} - - } - > - Filter connections - - {children} - - )} - > - Filter Options -
- - -
-
+ <> + + Filter connections + + ( + <> + } + > + + {isActivated && ( + + + + )} + + {children} + + )} + > + Filter Options +
+ + +
+
+ ); }