Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[bug]: ToolTipConent asChild breaks #6750

Open
2 tasks done
jhernandezb opened this issue Feb 23, 2025 · 1 comment
Open
2 tasks done

[bug]: ToolTipConent asChild breaks #6750

jhernandezb opened this issue Feb 23, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@jhernandezb
Copy link

Describe the bug

Radix tooltip when content is used as child is expecting exactly one children, but in v4 an arrow was introduced to the content breaking it

{children}
<TooltipPrimitive.Arrow className="bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" />

Affected component/components

Tooltip

How to reproduce

 <TooltipProvider>
      <TooltipTrigger asChild>
        <span className="inline-flex">Trigger</span>
      </TooltipTrigger>
      <TooltipContent asChild>
        <div >
          some content
        </div>
      </TooltipContent>
    </TooltipProvider>

Codesandbox/StackBlitz link

No response

Logs

System Info

shadcn@canary, tailwind v4, react 19

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues
@jhernandezb jhernandezb added the bug Something isn't working label Feb 23, 2025
@haratake22
Copy link

I've researched this issue and would like to share my findings.
Hope this helps.

Most likely, the problem is caused by using asChild on the TooltipContent component.
The TooltipPrimitive.Arrow arrow will display even without adding asChild to the TooltipContent.

The reason why adding asChild to TooltipContent causes an error is likely because TooltipPrimitive.Content, which is wrapped by TooltipContent, has asChild set to false by default in radix-ui.

https://github.com/radix-ui/themes/blob/main/packages/radix-ui-themes/src/components/tooltip.tsx

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants