Skip to content

Commit b83544a

Browse files
[RaisedButton] Fix the icon style override as done in mui#4754
1 parent 2884b07 commit b83544a

3 files changed

Lines changed: 23 additions & 3 deletions

File tree

src/FlatButton/FlatButton.spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,14 @@ describe('<FlatButton />', () => {
181181
assert.strictEqual(wrapper.state().hovered, false, 'should reset the state');
182182
});
183183
});
184+
185+
describe('props: icon', () => {
186+
it('should keep the style set on the icon', () => {
187+
const wrapper = shallowWithContext(
188+
<FlatButton icon={<ActionAndroid style={{foo: 'bar'}} />} />
189+
);
190+
191+
assert.strictEqual(wrapper.find(ActionAndroid).props().style.foo, 'bar');
192+
});
193+
});
184194
});

src/RaisedButton/RaisedButton.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {Component, PropTypes} from 'react';
1+
import React, {Component, cloneElement, PropTypes} from 'react';
22
import transitions from '../styles/transitions';
33
import {fade} from '../utils/colorManipulator';
44
import {createChildFragment} from '../utils/childUtils';
@@ -362,9 +362,9 @@ class RaisedButton extends Component {
362362
</span>
363363
);
364364

365-
const iconCloned = icon && React.cloneElement(icon, {
365+
const iconCloned = icon && cloneElement(icon, {
366366
color: icon.props.color || styles.label.color,
367-
style: styles.icon,
367+
style: Object.assign(styles.icon, icon.props.style),
368368
});
369369

370370
// Place label before or after children.

src/RaisedButton/RaisedButton.spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,14 @@ describe('<RaisedButton />', () => {
146146
assert.strictEqual(wrapper.state().hovered, false, 'should reset the state');
147147
});
148148
});
149+
150+
describe('props: icon', () => {
151+
it('should keep the style set on the icon', () => {
152+
const wrapper = shallowWithContext(
153+
<RaisedButton icon={<ActionAndroid style={{foo: 'bar'}} />} />
154+
);
155+
156+
assert.strictEqual(wrapper.find(ActionAndroid).props().style.foo, 'bar');
157+
});
158+
});
149159
});

0 commit comments

Comments
 (0)