fix: interactivity for components within tooltip body [INS-4773] (#8239)

Attempting to click on links within tooltips would lead to the tooltip being dismissed. This fixes the issue by moving the tooltip to be a sibling of the tooltip trigger, which is the correct structure for react-aria tooltips. Ref: https://react-spectrum.adobe.com/react-aria/useTooltipTrigger.html
This commit is contained in:
Vivek Thuravupala
2024-12-11 13:50:20 -08:00
committed by GitHub
parent d6a6bcb04d
commit eca35d832b

View File

@@ -49,14 +49,16 @@ export const Tooltip = (props: Props) => {
});
return (
<div
ref={triggerRef}
className={tooltipClasses}
style={{ position: 'relative', ...style }}
{...trigger.triggerProps}
onClick={props.onClick}
>
{children}
<>
<div
ref={triggerRef}
className={tooltipClasses}
style={{ position: 'relative', ...style }}
{...trigger.triggerProps}
onClick={props.onClick}
>
{children}
</div>
{state.isOpen && (
<OverlayContainer>
<div
@@ -69,6 +71,6 @@ export const Tooltip = (props: Props) => {
</div>
</OverlayContainer>
)}
</div>
</>
);
};