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

[Tab] SVG icon takes color from Icon's color props as well.. #7107

Closed
wants to merge 5 commits into from
Closed
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
16 changes: 12 additions & 4 deletions src/Tabs/Tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,18 @@ class Tab extends Component {
};
// If it's svg icon set color via props
if (icon.type.muiName !== 'FontIcon') {
if (icon.props !== undefined && icon.props.style !== undefined && icon.props.style.color !== undefined) {
iconProps.color = icon.props.style.color;
} else {
iconProps.color = styles.root.color;
if (icon.props) {
Copy link
Member

Choose a reason for hiding this comment

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

This all logic is getting too much complex. I think that the correct fix is the following:

// If it's svg icon set color via props
if (icon.type.muiName === 'SvgIcon') {
  iconProps.color = icon.props.color || styles.root.color;
}

Copy link
Member

Choose a reason for hiding this comment

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

It would be perfect if you could add some unit test to ensure it.

if (icon.props.style && icon.props.style.color) {
iconProps.color = icon.props.style.color;
} else if (icon.props.color) {
iconProps.color = icon.props.color;
} else {
iconProps.color = styles.root.color;
}

if (icon.props.hoverColor) {
iconProps.hoverColor = icon.props.hoverColor;
}
}
}
iconElement = React.cloneElement(icon, iconProps);
Expand Down