Skip to content

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

Gdgt 2590 replace deprecated tooltip component (#76117)

Egor Grushine3ce080ee8da
diff --git a/bun.lock b/bun.lock
index cd1e12a25c7..2ea9521bb5f 100644
--- a/bun.lock
+++ b/bun.lock
@@ -45,7 +45,6 @@
"@snowplow/browser-tracker": "3.2.0",
"@tanstack/react-table": "^8.21.3",
"@tanstack/react-virtual": "^3.13.2",
- "@tippyjs/react": "^4.2.6",
"@tiptap/core": "^3.2.0",
"@tiptap/extension-blockquote": "^3.15.3",
"@tiptap/extension-bold": "^3.15.3",
@@ -1636,8 +1635,6 @@
"@testing-library/user-event": ["@testing-library/[email protected]", "", {}, "sha512-YAh82Wh4TIrxYLmfGcixwD18oIjyC1pFQC2Y01F2lzV2HTMiYrI0nze0FD0ocB//CKS/7jIUgae+adPqxK5yCQ=="],
- "@tippyjs/react": ["@tippyjs/[email protected]", "", { "dependencies": { "tippy.js": "^6.3.1" } }, "sha512-91RicDR+H7oDSyPycI13q3b7o4O60wa2oRbjlz2fyRLmHImc4vyDwuUP8NtZaN0VARJY5hybvDYrFzhY9+Lbyw=="],
-
"@tiptap/core": ["@tiptap/[email protected]", "", {}, "sha512-1Dk1AIwzJejcyi4FOEcKoBSLMkHMfxeDiQ0daG51eS1IZ1ZSF+Xlhg9OD5sAjbUTGQjK1HfU6kGwS9wJcR/9ZQ=="],
"@tiptap/extension-blockquote": ["@tiptap/[email protected]", "", { "peerDependencies": { "@tiptap/core": "^3.15.3" } }, "sha512-13x5UsQXtttFpoS/n1q173OeurNxppsdWgP3JfsshzyxIghhC141uL3H6SGYQLPU31AizgDs2OEzt6cSUevaZg=="],
@@ -5810,8 +5807,6 @@
"@testing-library/jest-dom/dom-accessibility-api": ["[email protected]", "", {}, "sha512-7ZgogeTnjuHbo+ct10G9Ffp0mif17idi0IyWNVA/wcwcm7NPOD/WEHVP3n7n3MhXqxoIYm8d6MuZohYWIZ4T3w=="],
- "@tippyjs/react/tippy.js": ["[email protected]", "", { "dependencies": { "@popperjs/core": "^2.9.0" } }, "sha512-B9hAQ5KNF+jDJRg6cRysV6Y3J+5fiNfD60GuXR5TP0sfrcltpgdzVc7f1wMtjQ3W0+Xsy80CDvk0Z+Vr0cM4sQ=="],
-
"@tiptap/extension-bubble-menu/@floating-ui/dom": ["@floating-ui/[email protected]", "", { "dependencies": { "@floating-ui/core": "^1.6.0", "@floating-ui/utils": "^0.2.8" } }, "sha512-NP83c0HjokcGVEMeoStg317VD9W7eDlGK7457dMBANbKA6GJZdc7rjujdgqzTaz93jkGgc5P/jeWbaCHnMNc+w=="],
"@tiptap/react/@types/use-sync-external-store": ["@types/[email protected]", "", {}, "sha512-zFDAD+tlpf2r4asuHEj0XH6pY6i0g5NeAHPn+15wk3BV6JA69eERFXC1gyGThDkVa1zCyKr5jox1+2LbV/AMLg=="],
@@ -7406,8 +7401,6 @@
"@svgr/plugin-svgo/cosmiconfig/parse-json": ["[email protected]", "", { "dependencies": { "@babel/code-frame": "^7.0.0", "error-ex": "^1.3.1", "json-parse-even-better-errors": "^2.3.0", "lines-and-columns": "^1.1.6" } }, "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg=="],
- "@tippyjs/react/tippy.js/@popperjs/core": ["@popperjs/[email protected]", "", {}, "sha512-IXf3XA7+XyN7CP9gGh/XB0UxVMlvARGEgGXLubFICsUMGz6Q+DU+i4gGlpOxTjKvXjkJDJC8YdqdKkDj9qZHEQ=="],
-
"@tiptap/extension-bubble-menu/@floating-ui/dom/@floating-ui/core": ["@floating-ui/[email protected]", "", { "dependencies": { "@floating-ui/utils": "^0.2.8" } }, "sha512-7XJ9cPU+yI2QeLS+FCSlqNFZJq8arvswefkZrYI1yQBbftw6FyrZOxYSh+9S7z7TpeWlRt9zJ5IhM1WIL334jA=="],
"@tiptap/extension-bubble-menu/@floating-ui/dom/@floating-ui/utils": ["@floating-ui/[email protected]", "", {}, "sha512-kym7SodPp8/wloecOpcmSnWJsK7M0E5Wg8UcFA+uO4B9s5d0ywXOEro/8HM9x0rW+TljRzul/14UYz3TleT3ig=="],
diff --git a/e2e/test/scenarios/visualizations-charts/bar_chart.cy.spec.js b/e2e/test/scenarios/visualizations-charts/bar_chart.cy.spec.js
index 398ecbfedf7..840c472c8d0 100644
--- a/e2e/test/scenarios/visualizations-charts/bar_chart.cy.spec.js
+++ b/e2e/test/scenarios/visualizations-charts/bar_chart.cy.spec.js
@@ -1047,7 +1047,7 @@ describe("scenarios > visualizations > bar chart", () => {
H.echartsContainer().findByText("Goal").trigger("mousemove");
- H.popover().within(() => {
+ H.tooltip().within(() => {
cy.findByText("Goal:").should("exist");
cy.findByText("87.5%").should("exist");
});
diff --git a/e2e/test/scenarios/visualizations-charts/line_chart.cy.spec.js b/e2e/test/scenarios/visualizations-charts/line_chart.cy.spec.js
index 26f73424d15..93a09d99ad0 100644
--- a/e2e/test/scenarios/visualizations-charts/line_chart.cy.spec.js
+++ b/e2e/test/scenarios/visualizations-charts/line_chart.cy.spec.js
@@ -709,7 +709,7 @@ describe("scenarios > visualizations > line chart", () => {
H.echartsContainer().findByText("$50.0k").should("exist");
H.echartsContainer().findByText("Goal").trigger("mousemove");
- H.popover().within(() => {
+ H.tooltip().within(() => {
cy.findByText("Goal:").should("exist");
cy.findByText("$5,000.00").should("exist");
});
@@ -734,7 +734,7 @@ describe("scenarios > visualizations > line chart", () => {
H.echartsContainer().findByText("50.0k%").should("exist");
H.echartsContainer().findByText("Goal").trigger("mousemove");
- H.popover().within(() => {
+ H.tooltip().within(() => {
cy.findByText("Goal:").should("exist");
cy.findByText("12,345.67%").should("exist");
});
diff --git a/e2e/test/scenarios/visualizations-charts/maps.cy.spec.js b/e2e/test/scenarios/visualizations-charts/maps.cy.spec.js
index 327814ebd87..47d57ad87cf 100644
--- a/e2e/test/scenarios/visualizations-charts/maps.cy.spec.js
+++ b/e2e/test/scenarios/visualizations-charts/maps.cy.spec.js
@@ -133,7 +133,7 @@ describe("scenarios > visualizations > maps", () => {
cy.get(".leaflet-marker-icon").eq(2).as("blastoiseMarker");
cy.get("@blastoiseMarker").trigger("mousemove");
- H.popover().findByText("Blastoise").should("be.visible");
+ H.tooltip().findByText("Blastoise").should("be.visible");
});
it("should preserve zoom and pan after resize (metabase#11211)", () => {
diff --git a/e2e/test/scenarios/visualizations-charts/visualizations-charts-reproductions.cy.spec.js b/e2e/test/scenarios/visualizations-charts/visualizations-charts-reproductions.cy.spec.js
index 08048934cbf..0e2711b22bb 100644
--- a/e2e/test/scenarios/visualizations-charts/visualizations-charts-reproductions.cy.spec.js
+++ b/e2e/test/scenarios/visualizations-charts/visualizations-charts-reproductions.cy.spec.js
@@ -399,7 +399,7 @@ describe("issue 18063", () => {
cy.get(".leaflet-marker-icon").trigger("mousemove");
- H.popover().within(() => {
+ H.tooltip().within(() => {
H.testPairedTooltipValues("LATITUDE", "55.68");
H.testPairedTooltipValues("LONGITUDE", "12.57");
H.testPairedTooltipValues("COUNT", "1");
diff --git a/frontend/src/metabase/common/components/Tooltip/Tooltip.stories.tsx b/frontend/src/metabase/common/components/Tooltip/Tooltip.stories.tsx
deleted file mode 100644
index 13aa6c4345a..00000000000
--- a/frontend/src/metabase/common/components/Tooltip/Tooltip.stories.tsx
+++ /dev/null
@@ -1,45 +0,0 @@
-import type { StoryFn } from "@storybook/react";
-
-import { Tooltip } from "./Tooltip";
-
-export default {
- title: "Deprecated/Components/Tooltip",
- component: Tooltip,
-};
-
-const Template: StoryFn<typeof Tooltip> = (args) => {
- return <Tooltip {...args}>Hover me</Tooltip>;
-};
-
-export const Default = {
- render: Template,
- args: { tooltip: "Tooltip text" },
-};
-
-export const Controlled = {
- render: Template,
- args: { tooltip: "Controlled tooltip", isOpen: true },
-};
-
-export const CustomContent = {
- render: Template,
-
- args: {
- tooltip: (
- <div>
- <div style={{ background: "blue" }}>Blue</div>
- <div style={{ background: "red" }}>Red</div>
- </div>
- ),
- },
-};
-
-export const LongScalarString = {
- render: Template,
-
- args: {
- tooltip:
- "looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong string",
- isOpen: true,
- },
-};
diff --git a/frontend/src/metabase/common/components/Tooltip/Tooltip.tsx b/frontend/src/metabase/common/components/Tooltip/Tooltip.tsx
deleted file mode 100644
index a0d29c7832d..00000000000
--- a/frontend/src/metabase/common/components/Tooltip/Tooltip.tsx
+++ /dev/null
@@ -1,127 +0,0 @@
-import * as Tippy from "@tippyjs/react";
-import cx from "classnames";
-import { useMemo } from "react";
-import * as ReactIs from "react-is";
-
-import ZIndex from "metabase/css/core/z-index.module.css";
-import { EMBEDDING_SDK_PORTAL_ROOT_ELEMENT_ID } from "metabase/embedding-sdk/config";
-import { isReducedMotionPreferred } from "metabase/utils/dom";
-import { isReactDOMTypeElement } from "metabase-types/guards";
-
-import "./tippy.module.css";
-
-const TippyComponent = Tippy.default;
-
-export interface TooltipProps extends Partial<
- Pick<
- Tippy.TippyProps,
- "delay" | "reference" | "placement" | "maxWidth" | "offset"
- >
-> {
- preventOverflow?: boolean;
- tooltip?: React.ReactNode;
- children?: React.ReactNode;
- isEnabled?: boolean;
- isOpen?: boolean;
- maxWidth?: string | number | undefined;
- isPadded?: boolean;
- className?: string;
-}
-
-// Tippy relies on child nodes forwarding refs, so when `children` is neither
-// a DOM element or a forwardRef, we need to wrap it in a span.
-function getSafeChildren(children: React.ReactNode) {
- if (isReactDOMTypeElement(children) || ReactIs.isForwardRef(children)) {
- return children;
- } else {
- return <span data-testid="tooltip-component-wrapper">{children}</span>;
- }
-}
-
-function getTargetProps(
- reference?: Element | React.RefObject<Element> | null,
- children?: React.ReactNode,
-) {
- if (reference) {
- return { reference };
- } else if (children != null) {
- return { children: getSafeChildren(children) };
- }
-}
-
-function appendTo() {
- return (
- document.getElementById(EMBEDDING_SDK_PORTAL_ROOT_ELEMENT_ID) ||
- document.body
- );
-}
-
-/**
- * @deprecated: use Tooltip from "metabase/ui"
- */
-export function Tooltip({
- tooltip,
- children,
- delay,
- reference,
- placement,
- offset,
- isEnabled,
- isOpen,
- isPadded = true,
- preventOverflow = false,
- maxWidth = 300,
- className,
-}: TooltipProps) {
- const visible = isOpen != null ? isOpen : undefined;
- const animationDuration = isReducedMotionPreferred() ? 0 : undefined;
- const disabled = isEnabled === false;
- const targetProps = getTargetProps(reference, children);
-
- const popperOptions = useMemo(
- () =>
- preventOverflow
- ? {
- modifiers: [
- {
- name: "preventOverflow",
- options: {
- altAxis: true,
- },
- },
- ],
- }
- : undefined,
- [preventOverflow],
- );
-
- // themes styles come from ./tippy.module.css
- // Tippy theming API: https://atomiks.github.io/tippyjs/v6/themes/
- const theme = `tooltip ${isPadded ? "" : "no-padding"}`;
-
- const zIndex = "var(--mb-overlay-z-index)" as unknown as number;
-
- if (tooltip && targetProps) {
- return (
- <TippyComponent
- theme={theme}
- className={cx("popover", ZIndex.Overlay, className)}
- zIndex={zIndex}
- appendTo={appendTo}
- content={tooltip}
- visible={visible}
- disabled={disabled}
- maxWidth={maxWidth}
- reference={reference}
- duration={animationDuration}
- delay={delay}
- placement={placement}
- offset={offset}
- popperOptions={popperOptions}
- {...targetProps}
- />
- );
- } else {
- return <>{children}</>;
- }
-}
diff --git a/frontend/src/metabase/common/components/Tooltip/Tooltip.unit.spec.tsx b/frontend/src/metabase/common/components/Tooltip/Tooltip.unit.spec.tsx
deleted file mode 100644
index 627ee49edd9..00000000000
--- a/frontend/src/metabase/common/components/Tooltip/Tooltip.unit.spec.tsx
+++ /dev/null
@@ -1,161 +0,0 @@
-import userEvent from "@testing-library/user-event";
-import { forwardRef, useState } from "react";
-
-import { render, screen } from "__support__/ui";
-
-import { Tooltip, type TooltipProps } from "./Tooltip";
-
-const defaultTooltip = "tooltip content";
-
-const defaultTarget = (
- <div id="child-target" style={{ width: 100, height: 100 }}>
- child target element
- </div>
-);
-
-function setup({
- target = defaultTarget,
- tooltip = defaultTooltip,
- ...otherProps
-}: {
- target?: JSX.Element;
-} & TooltipProps = {}) {
- return render(
- <div>
- <Tooltip tooltip={tooltip} {...otherProps}>
- {target}
- </Tooltip>
- </div>,
- );
-}
-
-describe("Tooltip", () => {
- it("should be visible on hover of child target element", async () => {
- setup();
- await userEvent.hover(screen.getByText("child target element"));
- expect(screen.getByText("tooltip content")).toBeInTheDocument();
- });
-
- describe("isOpen", () => {
- it("should override hover behavior", async () => {
- setup({ isOpen: false });
-
- await userEvent.hover(screen.getByText("child target element"));
- expect(screen.queryByText("tooltip content")).not.toBeInTheDocument();
- });
-
- it("should be visible when isOpen is set to true", () => {
- setup({ isOpen: true });
- expect(screen.getByText("tooltip content")).toBeInTheDocument();
- });
- });
-
- describe("isEnabled", () => {
- it("should override hover behavior when false", async () => {
- setup({ isEnabled: false });
-
- await userEvent.hover(screen.getByText("child target element"));
- expect(screen.queryByText("tooltip content")).not.toBeInTheDocument();
- });
-
- it("should not override hover behavior when true", async () => {
- setup({ isEnabled: true });
-
- await userEvent.hover(screen.getByText("child target element"));
- expect(screen.getByText("tooltip content")).toBeInTheDocument();
- });
-
- it("should override isOpen when false", async () => {
- setup({ isEnabled: false, isOpen: true });
-
- await userEvent.hover(screen.getByText("child target element"));
- expect(screen.queryByText("tooltip content")).not.toBeInTheDocument();
- });
-
- it("should not override isOpen when true", async () => {
- setup({ isEnabled: true, isOpen: true });
-
- await userEvent.hover(screen.getByText("child target element"));
- expect(screen.getByText("tooltip content")).toBeInTheDocument();
- });
- });
-
- it("should wrap target Components without forwarded refs in a <span>", () => {
- function BadTarget() {
- return <div>bad target</div>;
- }
-
- setup({ isOpen: true, target: <BadTarget /> });
-
- const tooltip = screen.getByTestId("tooltip-component-wrapper");
-
- expect(tooltip).toBeInTheDocument();
- expect(tooltip).toHaveTextContent("bad target");
- });
-
- it("should not wrap target Components with forwarded refs", () => {
- const GoodTarget = forwardRef<HTMLDivElement>(
- function GoodTarget(props, ref) {
- return <div ref={ref}>good target</div>;
- },
- );
-
- setup({ isOpen: true, target: <GoodTarget /> });
-
- expect(
- screen.queryByTestId("tooltip-component-wrapper"),
- ).not.toBeInTheDocument();
- expect(screen.getByText("good target")).toBeInTheDocument();
- });
-
- it("should not wrap targets that are JSX dom elements", () => {
- setup({ isOpen: true, target: <div>good target</div> });
-
- expect(
- screen.queryByTestId("tooltip-component-wrapper"),
- ).not.toBeInTheDocument();
- expect(screen.getByText("good target")).toBeInTheDocument();
- });
-
- it("should still render children when not given tooltip content", () => {
- setup({ isOpen: true, tooltip: null });
-
- expect(screen.getByText("child target element")).toBeInTheDocument();
- // eslint-disable-next-line testing-library/no-node-access
- expect(document.querySelector(".tippy-box")).toBeNull();
- });
-
- it("should be themed as a tooltip", () => {
- setup({ isOpen: true });
- expect(screen.getByRole("tooltip")).toHaveAttribute(
- "data-theme",
- "tooltip ",
- );
- });
-
- it("should support using a reference element instead of a child target element", async () => {
- function ReferenceTooltipTest() {
- const [eventTarget, setEventTarget] = useState<HTMLDivElement>();
- return (
- <div>
- <Tooltip reference={eventTarget} tooltip="reference tooltip" isOpen />
- <div
- onClick={(event) => {
- setEventTarget(event.target as HTMLDivElement);
- }}
- style={{ width: 100, height: 100 }}
- >
- sibling element
- </div>
- </div>
- );
- }
-
- render(<ReferenceTooltipTest />);
- expect(screen.queryByText("reference tooltip")).not.toBeInTheDocument();
-
- await userEvent.click(screen.getByText("sibling element"));
-
- expect(screen.getByText("reference tooltip")).toBeInTheDocument();
- });
-});
diff --git a/frontend/src/metabase/common/components/Tooltip/index.ts b/frontend/src/metabase/common/components/Tooltip/index.ts
deleted file mode 100644
index cf5cc016b7f..00000000000
--- a/frontend/src/metabase/common/components/Tooltip/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export { Tooltip } from "./Tooltip";
-export type { TooltipProps } from "./Tooltip";
diff --git a/frontend/src/metabase/common/components/Tooltip/tippy.module.css b/frontend/src/metabase/common/components/Tooltip/tippy.module.css
deleted file mode 100644
index 731c7ec58ec..00000000000
--- a/frontend/src/metabase/common/components/Tooltip/tippy.module.css
+++ /dev/null
@@ -1,32 +0,0 @@
-/* TODO: Remove this file when tippy.js dependency is removed */
-
-/* Global classes from tippy.js */
-:global(.tippy-box),
-:global(.tippy-content) {
- max-height: inherit;
- transition:
- transform 0s,
- visibility 0.3s,
- opacity 0.3s;
-}
-
-:global(.tippy-box[data-theme~="tooltip"]) {
- color: var(--mb-color-tooltip-text);
- font-weight: bold;
- background-color: var(--mb-color-tooltip-background);
- border: none;
- pointer-events: none;
- line-height: 1.26;
- font-size: 12px;
- border-radius: 6px;
- box-shadow: 0 4px 10px var(--mb-color-shadow);
- overflow-wrap: break-word;
-}
-
-:global(.tippy-box[data-theme~="tooltip"] .tippy-content) {
- padding: 10px 12px;
-}
-
-:global(.tippy-box[data-theme~="no-padding"] .tippy-content) {
- padding: 0;
-}
diff --git a/frontend/src/metabase/visualizations/components/ChartTooltip/ChartTooltip.tsx b/frontend/src/metabase/visualizations/components/ChartTooltip/ChartTooltip.tsx
index f4dcc4ae976..c8810af7009 100644
--- a/frontend/src/metabase/visualizations/components/ChartTooltip/ChartTooltip.tsx
+++ b/frontend/src/metabase/visualizations/components/ChartTooltip/ChartTooltip.tsx
@@ -1,8 +1,8 @@
-import { useEffect, useMemo, useRef } from "react";
+import { type ReactNode, useMemo, useRef } from "react";
import _ from "underscore";
-import { Tooltip } from "metabase/common/components/Tooltip";
import { PLUGIN_CONTENT_TRANSLATION } from "metabase/plugins";
+import { Box, Portal, Tooltip } from "metabase/ui";
import { getEventTarget } from "metabase/utils/dom";
import type {
HoveredObject,
@@ -19,44 +19,27 @@ export interface ChartTooltipProps {
settings: VisualizationSettings;
}
-/**
- * Fixes a race condition where an ECharts rerender removes `element` before tippy can read its position
- */
-function useStableTooltipTarget(element: Element | undefined | null) {
- const proxyRef = useRef<HTMLDivElement | null>(null);
+type TargetRect = Pick<DOMRect, "left" | "top" | "width" | "height">;
- useEffect(() => {
- return () => {
- proxyRef.current?.remove();
- proxyRef.current = null;
- };
- }, []);
+const useStableTargetRect = (
+ element: Element | undefined | null,
+): TargetRect | null => {
+ const lastRectRef = useRef<TargetRect | null>(null);
if (!element) {
return null;
}
const rect = element.getBoundingClientRect();
+ // An ECharts rerender can momentarily detach `element`, leaving it with a 0x0
+ // rect; reuse the last known position so the tooltip doesn't jump or vanish.
if (rect.width === 0 && rect.height === 0) {
- return proxyRef.current;
- }
-
- if (!proxyRef.current) {
- proxyRef.current = document.createElement("div");
- proxyRef.current.style.position = "fixed";
- proxyRef.current.style.pointerEvents = "none";
- proxyRef.current.setAttribute("data-testid", "chart-tooltip-proxy");
- document.body.appendChild(proxyRef.current);
+ return lastRectRef.current;
}
- const proxy = proxyRef.current;
- proxy.style.left = `${rect.left}px`;
- proxy.style.top = `${rect.top}px`;
- proxy.style.width = `${rect.width}px`;
- proxy.style.height = `${rect.height}px`;
-
- return proxy;
-}
+ lastRectRef.current = rect;
+ return lastRectRef.current;
+};
export const ChartTooltipContent = ({
hovered,
@@ -100,27 +83,59 @@ const ChartTooltip = ({
);
}, [hovered]);
- const hasTargetEvent = hovered?.event != null;
- const proxyTarget = useStableTooltipTarget(hovered?.element);
- const isOpen = isNotEmpty && (proxyTarget != null || hasTargetEvent);
- const isPadded = hovered?.stackedTooltipModel == null;
-
- const target = proxyTarget
- ? proxyTarget
- : hovered?.event != null
- ? getEventTarget(hovered.event)
+ const stableRect = useStableTargetRect(hovered?.element);
+ const eventRect =
+ hovered?.event !== undefined
+ ? getEventTarget(hovered.event).getBoundingClientRect()
: null;
+ const targetRect = stableRect ?? eventRect;
+
+ const isOpen = isNotEmpty && targetRect !== null;
+
+ // Freeze the last content and rect so the tooltip fades out in place instead
+ // of blanking and jumping once `hovered` clears.
+ const lastDisplayRef = useRef<{
+ content: ReactNode;
+ rect: TargetRect;
+ isPadded: boolean;
+ } | null>(null);
+
+ if (isOpen) {
+ lastDisplayRef.current = {
+ content: tooltip,
+ rect: targetRect,
+ isPadded: !hovered?.stackedTooltipModel,
+ };
+ }
- return target ? (
- <Tooltip
- preventOverflow
- reference={target}
- isOpen={isOpen}
- isPadded={isPadded}
- tooltip={tooltip}
- maxWidth="unset"
- />
- ) : null;
+ const display = lastDisplayRef.current;
+
+ return (
+ <Portal>
+ <Tooltip
+ opened={isOpen}
+ label={display?.content ?? null}
+ styles={{
+ tooltip: {
+ maxWidth: "unset",
+ ...(display?.isPadded === false ? { padding: 0 } : null),
+ },
+ }}
+ >
+ <Box
+ data-testid="chart-tooltip-proxy"
+ style={{
+ position: "fixed",
+ left: display?.rect.left ?? 0,
+ top: display?.rect.top ?? 0,
+ width: display?.rect.width ?? 0,
+ height: display?.rect.height ?? 0,
+ pointerEvents: "none",
+ }}
+ />
+ </Tooltip>
+ </Portal>
+ );
};
// eslint-disable-next-line import/no-default-export -- deprecated usage
diff --git a/frontend/src/metabase/visualizations/components/ChartTooltip/KeyValuePairChartTooltip/KeyValuePairChartTooltip.module.css b/frontend/src/metabase/visualizations/components/ChartTooltip/KeyValuePairChartTooltip/KeyValuePairChartTooltip.module.css
index e2f2a7980b8..5f3d4fa446e 100644
--- a/frontend/src/metabase/visualizations/components/ChartTooltip/KeyValuePairChartTooltip/KeyValuePairChartTooltip.module.css
+++ b/frontend/src/metabase/visualizations/components/ChartTooltip/KeyValuePairChartTooltip/KeyValuePairChartTooltip.module.css
@@ -7,6 +7,7 @@
line-height: var(--mantine-spacing-sm);
content: " ";
display: block;
+ white-space: pre;
}
.tableCell {
@@ -28,5 +29,6 @@
line-height: var(--mantine-spacing-sm);
content: " ";
display: block;
+ white-space: pre;
}
}
diff --git a/frontend/src/metabase/visualizations/components/ChartTooltip/StackedDataTooltip/StackedDataTooltip.module.css b/frontend/src/metabase/visualizations/components/ChartTooltip/StackedDataTooltip/StackedDataTooltip.module.css
index 4212d498534..054344d307a 100644
--- a/frontend/src/metabase/visualizations/components/ChartTooltip/StackedDataTooltip/StackedDataTooltip.module.css
+++ b/frontend/src/metabase/visualizations/components/ChartTooltip/StackedDataTooltip/StackedDataTooltip.module.css
@@ -2,6 +2,7 @@
line-height: var(--mantine-spacing-sm);
content: " ";
display: block;
+ white-space: pre;
}
.dataPointTable {
@@ -18,4 +19,5 @@
line-height: var(--mantine-spacing-sm);
content: " ";
display: block;
+ white-space: pre;
}
diff --git a/package.json b/package.json
index 1a8e9f636db..e7c7164300a 100644
--- a/package.json
+++ b/package.json
@@ -54,7 +54,6 @@
"@snowplow/browser-tracker": "3.2.0",
"@tanstack/react-table": "^8.21.3",
"@tanstack/react-virtual": "^3.13.2",
- "@tippyjs/react": "^4.2.6",
"@tiptap/core": "^3.2.0",
"@tiptap/extension-blockquote": "^3.15.3",
"@tiptap/extension-bold": "^3.15.3",