From c4e81979ce49ef00e7d6bcfef9ad3ba7b74eae80 Mon Sep 17 00:00:00 2001 From: EthanHealy01 Date: Wed, 13 Aug 2025 17:38:00 +0100 Subject: [PATCH] fix flashing tooltip issue --- .../components/shared/AllToolsNavButton.tsx | 3 ++- .../src/components/shared/QuickAccessBar.tsx | 2 +- frontend/src/components/shared/Tooltip.tsx | 18 ++++++++++++------ .../shared/quickAccessBar/TopToolIndicator.tsx | 2 +- .../shared/tooltip/Tooltip.module.css | 1 - frontend/src/global.d.ts | 1 + 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/frontend/src/components/shared/AllToolsNavButton.tsx b/frontend/src/components/shared/AllToolsNavButton.tsx index cd1824693..79fd36ae1 100644 --- a/frontend/src/components/shared/AllToolsNavButton.tsx +++ b/frontend/src/components/shared/AllToolsNavButton.tsx @@ -29,7 +29,8 @@ const AllToolsNavButton: React.FC = ({ activeButton, set ); return ( - + +
(({ {buttonConfigs.slice(0, -1).map((config, index) => ( - +
void; arrow?: boolean; @@ -23,6 +24,7 @@ export interface TooltipProps { logo?: React.ReactNode; }; delay?: number; + containerStyle?: React.CSSProperties; } export const Tooltip: React.FC = ({ @@ -32,13 +34,15 @@ export const Tooltip: React.FC = ({ tips, children, offset: gap = 8, - maxWidth = 280, + maxWidth, + minWidth, open: controlledOpen, onOpenChange, arrow = false, portalTarget, header, delay = 0, + containerStyle={}, }) => { const [internalOpen, setInternalOpen] = useState(false); const [isPinned, setIsPinned] = useState(false); @@ -135,8 +139,8 @@ export const Tooltip: React.FC = ({ ''; }; - // Only show tooltip when position is ready and correct - const shouldShowTooltip = open && (sidebarTooltip ? positionReady : true); + // Always mount when open so we can measure; hide until positioned to avoid flash + const shouldShowTooltip = open; const tooltipElement = shouldShowTooltip ? (
= ({ position: 'fixed', top: coords.top, left: coords.left, - maxWidth, + width: (maxWidth !== undefined ? maxWidth : '25rem'), + minWidth: minWidth, zIndex: 9999, - visibility: 'visible', - opacity: 1, + visibility: positionReady ? 'visible' : 'hidden', + opacity: positionReady ? 1 : 0, color: 'var(--text-primary)', + ...containerStyle, }} className={`${styles['tooltip-container']} ${isPinned ? styles.pinned : ''}`} onClick={handleTooltipClick} diff --git a/frontend/src/components/shared/quickAccessBar/TopToolIndicator.tsx b/frontend/src/components/shared/quickAccessBar/TopToolIndicator.tsx index bae269303..43f238498 100644 --- a/frontend/src/components/shared/quickAccessBar/TopToolIndicator.tsx +++ b/frontend/src/components/shared/quickAccessBar/TopToolIndicator.tsx @@ -68,7 +68,7 @@ const TopToolIndicator: React.FC = ({ activeButton, setAc {indicatorTool && (
- +