* fix(ui): resolve React 19 ref deprecation warning in Tooltip (#30110) * fix(ui): preserve numeric tooltip content in Tooltip component guard
This commit is contained in:
@@ -1,10 +1,9 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import classNames from "@calcom/ui/classNames";
|
||||||
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
import classNames from "@calcom/ui/classNames";
|
|
||||||
|
|
||||||
export function Tooltip({
|
export function Tooltip({
|
||||||
children,
|
children,
|
||||||
content,
|
content,
|
||||||
@@ -40,13 +39,17 @@ export function Tooltip({
|
|||||||
</TooltipPrimitive.Content>
|
</TooltipPrimitive.Content>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (content === undefined || content === null || content === "") return <>{children}</>;
|
||||||
|
|
||||||
|
const trigger = React.isValidElement(children) ? children : <span>{children}</span>;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TooltipPrimitive.Root
|
<TooltipPrimitive.Root
|
||||||
delayDuration={delayDuration || 50}
|
delayDuration={delayDuration || 50}
|
||||||
open={open}
|
open={open}
|
||||||
defaultOpen={defaultOpen}
|
defaultOpen={defaultOpen}
|
||||||
onOpenChange={onOpenChange}>
|
onOpenChange={onOpenChange}>
|
||||||
<TooltipPrimitive.Trigger asChild>{children}</TooltipPrimitive.Trigger>
|
<TooltipPrimitive.Trigger asChild>{trigger}</TooltipPrimitive.Trigger>
|
||||||
<TooltipPrimitive.Portal>{Content}</TooltipPrimitive.Portal>
|
<TooltipPrimitive.Portal>{Content}</TooltipPrimitive.Portal>
|
||||||
</TooltipPrimitive.Root>
|
</TooltipPrimitive.Root>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user