Tooltip gives hydration error when placed into Accordion trigger
Closed this issue · 3 comments
Bug report
Current Behavior
Expected behavior
When placing a Tooltip inside AccordionTrigger
, it gives a hydration error in Next.JS:
Reproducible example
import {
Accordion,
AccordionContent,
AccordionItem,
AccordionTrigger,
} from "@radix-ui/react-accordion";
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from "@radix-ui/react-tooltip";
export default function Home() {
return (
<TooltipProvider>
<Accordion type="single">
<AccordionItem value="item-1">
<AccordionTrigger>
<Tooltip>
<TooltipTrigger>TOOLTIP TRIGGER</TooltipTrigger>
<TooltipContent>TOOLTIP TEXT</TooltipContent>
</Tooltip>
</AccordionTrigger>
<AccordionContent>CONTENT HERE</AccordionContent>
</AccordionItem>
</Accordion>
</TooltipProvider>
);
}
Your environment
Software | Name(s) | Version |
---|---|---|
Radix Package(s) | @radix-ui/react-accordion | 1.2.1 |
@radix-ui/react-tooltip | 1.1.3 | |
React | n/a | 18.3.5 |
Browser | Arc | 130.0.6723.59 (Official Build) (arm64) |
Assistive tech | ||
Node | n/a | 20.18.0 |
npm/yarn | bun (only as package manager) | 1.1.31 |
Operating System | MacOS | 15.1 (24B83) |
So, it caused because both TooltipTrigger
and AccardeonTrigger
are buttons, and you can't have button inside a button. But the question is, why are they buttons? I can maybe understand for accordion because it is clickable, but tooltip trigger isn't, it hoverable.
So, it caused because both
TooltipTrigger
andAccardeonTrigger
are buttons, and you can't have button inside a button. But the question is, why are they buttons? I can maybe understand for accordion because it is clickable, but tooltip trigger isn't, it hoverable.
In such cases, you can use the asChild
prop to give a span
for example.
They are buttons for accessibility's sake and they are designed with these specs in mind, having a tooltip over an accordion is a custom behaviour and its your responsibility to make sure you don't break these
That makes sense, thanks.