-
Notifications
You must be signed in to change notification settings - Fork 889
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
data-state
composition issue when composing multiple primitives with asChild
#602
Comments
Redundant now that we have |
In fact, the same applies with Ideally we would figure a way to have the state from both parts on the trigger still. There have been other discussions about this. |
A workaround is to control the component(s): #560 (comment) |
as={Component}
doesn't use data-state
from Component
data-state
composition issue when composing multiple primitives with asChild
Hey guys, I dive into it and found what's going on when you have this structure const DialogTrigger = (props) => {
const Comp = props.asChild ? Slot: 'button'
return <Comp {...props} />
}
const TooltipTrigger = (props) => {
const Comp = props.asChild ? Slot: 'button'
return <Comp {...props} />
}
<DialogTrigger asChild>
<TooltipTrigger />
</DialogTrigger> in the To get the PS.: The issue occurs with all props. The events are not composed, for example. Only if you do: onClick={event => {
props.onClick(event)
}} |
Oh we know what the composition issue is, it's just that there is no obvious solution on how to best compose Essentially, at the moment, there will always be one
I don't understand what you're saying here? |
Hmm, I think I misunderstood the Just to be sure, given this example <DialogTrigger asChild>
<TooltipTrigger />
</DialogTrigger> is the expected behavior that the props will merge between those of the rendered |
Another good example is using something like a
In this case, the |
We just ran into the same issue (with Tooltip and Tabs). We thought one possible solution to this could be that |
I have this same problem with tooltips and toggles :'( |
I think it will be better to append values to <Tooltip.Root>
<Tooltip.Trigger asChild>
<Toggle.Root pressed />
</Tooltip.Trigger>
</Tooltip.Root> The |
Had this exact same issue. Solved a bunch of other issues related to composing tooltips/popovers/etc from this discussion, but then noticed my tabs weren't being styled when selected, because of To fix this, in my tabs component I pulled out the selected tab state to a |
To have a global reusable component e.g., a Tooltip one can prevent the Tooltip from overwriting its children's "data-state" with a filter slot:
then the Tooltip looks like this:
|
Stemmed from this discussion #560 (comment)
When I did
<Dialog.Trigger as={Tooltip.Trigger}>
thedata-state
attribute was maintained fromDialog.Trigger
instead of being overridden with theTooltip.Trigger
one. I'm not sure if this is a misunderstanding ofas
prop on my part (they're a confusing beast) but thought it worth looking into as a DX improvement if possible.The text was updated successfully, but these errors were encountered: