Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix(frontend): keep the caller's trigger when a tooltip has nothing to say
zchpeter92b5d5d17a00
diff --git a/frontend/src/components/ui/tooltip.test.tsx b/frontend/src/components/ui/tooltip.test.tsxindex 2ce9083dc8..16dece1944 100644--- a/frontend/src/components/ui/tooltip.test.tsx+++ b/frontend/src/components/ui/tooltip.test.tsx@@ -38,6 +38,41 @@ describe("Tooltip", () => {document.body.innerHTML = "";});+ test.each([+ ["with a body", <span key="body">a deadline</span>],+ ["with nothing to say", undefined],+ ])("keeps the caller's trigger element %s", (_name, content) => {+ // The element carries the caller's layout, so a row must not gain or lose+ // it with the tooltip's content.+ const container = document.createElement("div");+ document.body.appendChild(container);+ const root = createRoot(container);+ act(() =>+ root.render(+ <Tooltip content={content} render={<span className="shrink-0" />}>+ 12:00+ </Tooltip>+ )+ );++ const trigger = container.querySelector(".shrink-0");+ expect(trigger).not.toBeNull();+ expect(trigger?.textContent).toBe("12:00");+ act(() => root.unmount());+ });++ test("blocks keep their block trigger when there is nothing to say", () => {+ const container = document.createElement("div");+ document.body.appendChild(container);+ const root = createRoot(container);+ act(() =>+ root.render(<BlockTooltip content={undefined}>a field</BlockTooltip>)+ );++ expect(container.querySelector(".flex-1")).not.toBeNull();+ act(() => root.unmount());+ });+test("mounts tooltip content into the overlay layer root", async () => {vi.useFakeTimers();const container = document.createElement("div");diff --git a/frontend/src/components/ui/tooltip.tsx b/frontend/src/components/ui/tooltip.tsxindex b428375173..4e3d383d92 100644--- a/frontend/src/components/ui/tooltip.tsx+++ b/frontend/src/components/ui/tooltip.tsx@@ -1,5 +1,6 @@import { Tooltip as BaseTooltip } from "@base-ui/react/tooltip";import type { ComponentProps, ReactNode } from "react";+import { cloneElement, isValidElement } from "react";import { cn } from "@/lib/utils";import { getLayerRoot, LAYER_SURFACE_CLASS } from "./layer";@@ -28,7 +29,15 @@ export function Tooltip({render,}: TooltipProps) {if (!content) {- return <>{children}</>;+ // A caller's `render` element carries that row's layout, not the tooltip's:+ // dropping it when there is nothing to say would move their classes onto a+ // grandchild in one state and not the other, which is a layout that breaks+ // only sometimes.+ return isValidElement(render) ? (+ cloneElement(render, undefined, children)+ ) : (+ <>{children}</>+ );}return (