Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

GDGT-3438: Only make tooltips hoverable once they've finished fading in (#85797)

Will Frye3b76efa2a4f
diff --git a/frontend/src/metabase/ui/components/overlays/Tooltip/Tooltip.mdx b/frontend/src/metabase/ui/components/overlays/Tooltip/Tooltip.mdx
index cab7b382daa..429e1e6c21a 100644
--- a/frontend/src/metabase/ui/components/overlays/Tooltip/Tooltip.mdx
+++ b/frontend/src/metabase/ui/components/overlays/Tooltip/Tooltip.mdx
@@ -15,7 +15,7 @@ Our themed wrapper around [Mantine Tooltip](https://mantine.dev/core/tooltip/).
## Behaviour
-A tooltip opened by hover stays open while the pointer is on it, so its content can be selected and links in it clicked ([WCAG 1.4.13](https://www.w3.org/WAI/WCAG22/Understanding/content-on-hover-or-focus.html)). It closes shortly after the pointer leaves both the target and the tooltip. Tooltips with a controlled `opened` prop don't take pointer events.
+Once a tooltip opened by hover has finished fading in, it stays open while the pointer is on it, so its content can be selected and links in it clicked ([WCAG 1.4.13](https://www.w3.org/WAI/WCAG22/Understanding/content-on-hover-or-focus.html)). Until then it lets the pointer through, so it doesn't get in the way of a pointer crossing its target. It closes shortly after the pointer leaves both the target and the tooltip. Tooltips with a controlled `opened` prop don't take pointer events.
## Examples
diff --git a/frontend/src/metabase/ui/components/overlays/Tooltip/Tooltip.unit.spec.tsx b/frontend/src/metabase/ui/components/overlays/Tooltip/Tooltip.unit.spec.tsx
index 47907a1bd7b..cfbfc53d570 100644
--- a/frontend/src/metabase/ui/components/overlays/Tooltip/Tooltip.unit.spec.tsx
+++ b/frontend/src/metabase/ui/components/overlays/Tooltip/Tooltip.unit.spec.tsx
@@ -150,6 +150,16 @@ describe("Tooltip", () => {
});
});
+ it("lets the pointer through until it has finished fading in", async () => {
+ const { user } = setup();
+
+ await user.hover(screen.getByRole("button", { name: "Target" }));
+ const tooltip = await screen.findByRole("tooltip");
+ expect(tooltip).not.toHaveAttribute("data-hoverable");
+
+ await waitFor(() => expect(tooltip).toHaveAttribute("data-hoverable"));
+ });
+
it("hides the previous tooltip straight away when the pointer moves to another target", async () => {
const { user } = setupNeighbouringTargets();
diff --git a/frontend/src/metabase/ui/components/overlays/Tooltip/use-tooltip-visibility.ts b/frontend/src/metabase/ui/components/overlays/Tooltip/use-tooltip-visibility.ts
index 8bbd8ba2853..8289228e958 100644
--- a/frontend/src/metabase/ui/components/overlays/Tooltip/use-tooltip-visibility.ts
+++ b/frontend/src/metabase/ui/components/overlays/Tooltip/use-tooltip-visibility.ts
@@ -70,7 +70,7 @@ export function useTooltipVisibility(
);
return {
- isHoverable: !isControlled && (phase === "entering" || phase === "open"),
+ isHoverable: !isControlled && phase === "open",
isReplaced,
isEnteringInstantly: isReplacing && phase === "entering",
transitionProps: resolvedTransitionProps,