-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[system][Stack] Fix displaying of rendering 0 when divider prop is passed #44126
base: master
Are you sure you want to change the base?
Conversation
Netlify deploy previewhttps://deploy-preview-44126--material-ui.netlify.app/ Bundle size reportDetails of bundle changes (Toolpad) |
if (child === 0) { | ||
return true; | ||
} | ||
return !!child; |
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.
- Shouldn't this be using
getValidReactChildren()
? - I guess we miss
if (isFragment(summary)) {
return new Error('Not accepting Fragments');
}
in getValidReactChildren()
- It looks like Stepper, SpeedDial, Breadcrumbs, AvatarGroup should use that helper too.
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.
Shouldn't this be using getValidReactChildren()?
Not sure about this, React.isValidElement
is being used inside getValidReactChildren
and React.isValidElement
is returning false when any number or strings are passed (attached reference for this below).
So if we want to directly render numbers or strings without wrapping in html tags/React components, i think these would get skipped.
Edit: ping @oliviertassinari
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.
@sai6855 I suspect it's a bug of getValidReactChildren()
. Looking at how it's used, we could expect "Three" to be shown in https://stackblitz.com/edit/react-wy3ghg?file=Demo.tsx no?
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.
And then, we could use
if (!title && title !== 0) { |
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.
we could expect "Three" to be shown in no?
It's interesting that you're expecting "Three" to be displayed. According to the ButtonGroup
definition from the docs and demos, if i place "Three" as an immediate child inside ButtonGroup
, I wouldn’t be surprised if it gets skipped or any non-Button elements gets skipped
However, in the case of Stack
, all numbers and strings are displayed except 0
, so I would consider this a bug.
Before preview: https://mui.com/material-ui/react-stack/#basics
after preview: https://deploy-preview-44126--material-ui.netlify.app/material-ui/react-stack/#basics
Place below code in both preview to see the difference, in
after preview
0 is rendered but not in before previewI was going through this issue #43969 and found logic mentioned here as bit weird as 0 would get skipped by
.filter(Boolean)