Skip to content

Commit 8d68fb9

Browse files
committed
Merge pull request #4160 from tintin1343/flatButton-icon
[FlatButton] Fix Icon color prop issue
2 parents 6a4a8bb + 76fb046 commit 8d68fb9

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/FlatButton/FlatButton.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class FlatButton extends Component {
221221

222222
if (icon) {
223223
iconCloned = React.cloneElement(icon, {
224-
color: mergedRootStyles.color,
224+
color: icon.props.color || mergedRootStyles.color,
225225
style: {
226226
verticalAlign: 'middle',
227227
marginLeft: label && labelPosition !== 'before' ? 12 : 0,

src/FlatButton/FlatButton.spec.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {shallow} from 'enzyme';
44
import {assert} from 'chai';
55
import FlatButton from './FlatButton';
66
import getMuiTheme from '../styles/getMuiTheme';
7+
import ActionAndroid from '../svg-icons/action/android';
78

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

96+
it('colors the icon with the passed color in prop', () => {
97+
const color = 'white';
98+
const wrapper = shallowWithContext(
99+
<FlatButton
100+
backgroundColor="#a4c639"
101+
hoverColor="#8AA62F"
102+
icon={<ActionAndroid color={color} />}
103+
/>
104+
);
105+
const icon = wrapper.find('ActionAndroid');
106+
assert.strictEqual(icon.prop('color'), color, 'icon should have same color as that of color prop');
107+
});
108+
95109
it('colors the button the secondary theme color', () => {
96110
const wrapper = shallowWithContext(
97111
<FlatButton secondary={true} icon={<span className="test-icon" />}>Button</FlatButton>

0 commit comments

Comments
 (0)