Fixed ShadTooltip appearing when Accordion is not disabled

This commit is contained in:
Lucas Oliveira 2024-06-14 18:19:13 -03:00
commit 55fdebe3bb
2 changed files with 7 additions and 5 deletions

View file

@ -10,7 +10,7 @@ export default function ShadTooltip({
styleClasses,
delayDuration = 500,
}: ShadToolTipType): JSX.Element {
return (
return content ? (
<Tooltip defaultOpen={!children} delayDuration={delayDuration}>
<TooltipTrigger asChild={asChild}>{children}</TooltipTrigger>
<TooltipContent
@ -22,5 +22,7 @@ export default function ShadTooltip({
{content}
</TooltipContent>
</Tooltip>
) : (
<>{children}</>
);
}

View file

@ -34,19 +34,19 @@ const AccordionTrigger = React.forwardRef<
<div
className={cn(
"flex flex-1 cursor-pointer items-center justify-between py-4 text-sm font-medium transition-all [&[data-state=open]>svg]:rotate-180",
className
className,
)}
>
{children}
<ShadTooltip
styleClasses="z-50"
content={disabled ? "Empty" : ""}
content={disabled ? "Empty" : undefined}
side="top"
>
<ChevronDownIcon
className={cn(
"h-4 w-4 font-bold transition-transform duration-200",
disabled ? "text-muted-foreground" : "text-primary"
disabled ? "text-muted-foreground" : "text-primary",
)}
/>
</ShadTooltip>
@ -64,7 +64,7 @@ const AccordionContent = React.forwardRef<
ref={ref}
className={cn(
"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm",
className
className,
)}
{...props}
>