Skip to content
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

[DialogActions] Fix allow have Children with null values #7504

Merged

Conversation

stvkoch
Copy link
Contributor

@stvkoch stvkoch commented Jul 21, 2017

Hello

DialogActions don't allow use, common partner, that select element you want to show or send null value.

You will find this case in the test file:

<DialogActions>
  {showButton ? <button className="woof">Hello</button> : null}
  {!showButton ? <button>false button</button> : null}
</DialogActions>

Use Children.toArray to remove null/undefined values and then avoid emit error when trying access props of children.

@@ -27,7 +27,7 @@ function DialogActions(props) {

return (
<div data-mui-test="DialogActions" className={classNames(classes.root, className)} {...other}>
{Children.map(children, button =>
{Children.map(Children.toArray(children), button =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's bad for perf, can we use isValidElement instead?

@oliviertassinari oliviertassinari added component: dialog This is the name of the generic UI component, not the React module! PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI v1 labels Jul 21, 2017
@oliviertassinari oliviertassinari merged commit 07bd1d9 into mui:v1-alpha Jul 22, 2017
@oliviertassinari oliviertassinari added PR: Review Accepted and removed PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI labels Jul 22, 2017
@oliviertassinari
Copy link
Member

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: dialog This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants