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

[toolbar-group] Fixed error when a child element is null #847

Merged
merged 1 commit into from
Jun 15, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/toolbar/toolbar-group.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var ToolbarGroup = React.createClass({
float: 'left'
};
},

getTheme: function() {
return this.context.muiTheme.component.toolbar;
},
Expand All @@ -44,7 +44,7 @@ var ToolbarGroup = React.createClass({
display: 'inline-block',
marginRight: this.getSpacing()
},
controlBg: {
controlBg: {
backgroundColor: this.getTheme().menuHoverColor,
borderRadius: 0
},
Expand Down Expand Up @@ -86,8 +86,11 @@ var ToolbarGroup = React.createClass({
if (this.props.lastChild) styles.marginRight = -24;

var newChildren = React.Children.map(this.props.children, function(currentChild) {
if(!currentChild) {
return null;
}
switch (currentChild.type.displayName) {
case 'DropDownMenu' :
case 'DropDownMenu' :
return React.cloneElement(currentChild, {
style: styles.dropDownMenu.root,
styleControlBg: styles.dropDownMenu.controlBg,
Expand All @@ -104,13 +107,13 @@ var ToolbarGroup = React.createClass({
return React.cloneElement(currentChild, {
style: styles.button
});
case 'FontIcon' :
case 'FontIcon' :
return React.cloneElement(currentChild, {
style: styles.icon.root,
onMouseOver: this._handleMouseOverFontIcon,
onMouseOut: this._handleMouseOutFontIcon
});
case 'ToolbarSeparator' : case 'ToolbarTitle' :
case 'ToolbarSeparator' : case 'ToolbarTitle' :
return React.cloneElement(currentChild, {
style: this.mergeStyles(styles.span, currentChild.props.style)
});
Expand Down