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
[Slot] Fix children expectation when using Slottable
#1376
Conversation
|
@andy-hook Not approving the chromatic changes yet as I want to discuss them with you on a call first. |
packages/react/slot/src/Slot.tsx
Outdated
if (React.Children.count(slottableChildren) > 1) return React.Children.only(null); | ||
return React.isValidElement(slottableChildren) | ||
? (slottableChildren.props.children as React.ReactNode) | ||
: null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth us providing some comments to explain the flow here? the children of children is a bit of a mind bender without context. Hard to know if I'm finding it easier to follow simply because I already have that context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added comments but also re-wrote it a bit which I think makes it easier to read.
Let me know your thoughts: cb531c0
* [Slot] Fix children expectation when using Slottable Fixes radix-ui#1261 * Fix regression caught by Chromatic * Add tests * Replace with snapshot tests * PR feedback
Fixes #1261