-
Notifications
You must be signed in to change notification settings - Fork 852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tooltip positioning doesn't work within a CSS container query #3143
Comments
I believe this is related to this breaking change in chromium, which was the result of this change in the CSS specification. The change also broke I think every floating radix-ui element inside a I am not sure if the radix-ui team can do anything to fix this (because the change broke the usage, not the library), but you can try adding Using |
This didn't work on my side, but moving the Content inside a Portal did.
|
moving inside a portal also works for me! |
Works for me <CardHeader
className='flex flex-row items-center gap-2 flex-wrap @container/header space-y-0'
style={{ contain: 'layout' }} <-----
>
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
<Button variant='outline'>Hover</Button>
</TooltipTrigger>
<TooltipContent>
<p>Add to library</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
</CardHeader>
``` |
A solution should be provided by radix ui |
Bug report
Current Behavior
When a Tooltip (i.e. Root, Trigger, and Content) is placed inside a div with the CSS
container-type: inline-size
then the Tooltip Content isn't properly positioned (it's positioned way off to the side).However if the Tooltip Content is placed inside a Tooltip Portal, then it is properly positioned adjacent to the Trigger.
Expected behavior
The Tooltip Content should always appear adjacent to the Trigger
Reproducible example
Example on StackBlitz
Suggested solution
Either have the Content positioning work with container queries regardless of whether the Tooltip Portal is used, or make it clear in the documentation that the Portal is required when nesting inside CSS container queries.
Additional context
Your environment
The text was updated successfully, but these errors were encountered: