Skip to content

Commit

Permalink
[FlatButton] Fix Icon color prop issue
Browse files Browse the repository at this point in the history
Closes mui#4144
  • Loading branch information
tintin1343 committed May 6, 2016
1 parent 014476d commit 76fb046
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/FlatButton/FlatButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class FlatButton extends Component {

if (icon) {
iconCloned = React.cloneElement(icon, {
color: mergedRootStyles.color,
color: icon.props.color || mergedRootStyles.color,
style: {
verticalAlign: 'middle',
marginLeft: label && labelPosition !== 'before' ? 12 : 0,
Expand Down
14 changes: 14 additions & 0 deletions src/FlatButton/FlatButton.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {shallow} from 'enzyme';
import {assert} from 'chai';
import FlatButton from './FlatButton';
import getMuiTheme from '../styles/getMuiTheme';
import ActionAndroid from '../svg-icons/action/android';

describe('<FlatButton />', () => {
const muiTheme = getMuiTheme();
Expand Down Expand Up @@ -92,6 +93,19 @@ describe('<FlatButton />', () => {
assert.ok(icon.is({color: flatButtonTheme.primaryTextColor}));
});

it('colors the icon with the passed color in prop', () => {
const color = 'white';
const wrapper = shallowWithContext(
<FlatButton
backgroundColor="#a4c639"
hoverColor="#8AA62F"
icon={<ActionAndroid color={color} />}
/>
);
const icon = wrapper.find('ActionAndroid');
assert.strictEqual(icon.prop('color'), color, 'icon should have same color as that of color prop');
});

it('colors the button the secondary theme color', () => {
const wrapper = shallowWithContext(
<FlatButton secondary={true} icon={<span className="test-icon" />}>Button</FlatButton>
Expand Down

0 comments on commit 76fb046

Please sign in to comment.