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

[Menu] add checks to prevent error for null child #2429

Merged
merged 1 commit into from
Dec 10, 2015

Conversation

alitaheri
Copy link
Member

Closes #2067.

@alitaheri
Copy link
Member Author

I'm not sure. Should we also filter before mapping at this line, to make the count equal to number of non-null children? @oliviertassinari What do you think?

@oliviertassinari
Copy link
Member

Yeap, I think that it's a good idea to create a filtered children array.
Then passed this array to methods that need to iterate it.

@oliviertassinari oliviertassinari added the PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI label Dec 8, 2015
@alitaheri
Copy link
Member Author

@oliviertassinari Please take another look.

@alitaheri alitaheri added Review: review-needed new feature New feature or request 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 Enhancement labels Dec 8, 2015
let menuItemCount = 0;
React.Children.forEach(this.props.children, (child) => {
for (let child of filteredChildren) {
Copy link
Member

Choose a reason for hiding this comment

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

for ... of ... is not supported by IE (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of)
Shouldn't we use forEach?

Copy link
Member Author

Choose a reason for hiding this comment

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

babel transforms this. see the emitted code

but I can change it if you want. I just thought it's more expressive.

Copy link
Member

Choose a reason for hiding this comment

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

Hum, I didn't check, but I remember this issue #1972.

Copy link
Member Author

Choose a reason for hiding this comment

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

In my output I see the transformation, but let's not take any chances. Alright I'll Fix this. Thanks for the tip 👍 👍

@oliviertassinari oliviertassinari added PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI and removed PR: Needs Review labels Dec 9, 2015
@alitaheri alitaheri modified the milestone: 0.14.0 Release Dec 9, 2015
@alitaheri
Copy link
Member Author

@oliviertassinari This is ready. if it's Ok I'll rebase and merge. 😬

@alitaheri alitaheri added PR: Needs Review and removed new feature New feature or request PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI labels Dec 9, 2015
@oliviertassinari
Copy link
Member

@subjectix Yes, could you squash down?

@alitaheri alitaheri force-pushed the menu-handle-null-child branch from 25ddd3b to 8d5ce9f Compare December 10, 2015 13:37
alitaheri added a commit that referenced this pull request Dec 10, 2015
[Menu] add checks to prevent error for null child
@alitaheri alitaheri merged commit 2e95797 into mui:master Dec 10, 2015
@alitaheri alitaheri deleted the menu-handle-null-child branch December 10, 2015 13:53
smcguinness added a commit to smcguinness/material-ui that referenced this pull request Oct 15, 2016
mui#2429 allowed for null children in Menu, however, DropDownMenu threw an exception at Line 272 when child was null when doing a check for a matching value to display.
@zannager zannager added the component: menu This is the name of the generic UI component, not the React module! label Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: menu 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.

[MenuItem] Add support for hidden flag
3 participants