Skip to content

Commit

Permalink
[Stepper] Prevent overriding Step's props (#13188)
Browse files Browse the repository at this point in the history
* Override step props over internal state of stepper

* add a unit test
  • Loading branch information
nikhilem authored and oliviertassinari committed Oct 10, 2018
1 parent f11ae66 commit 9085831
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/material-ui/src/Stepper/Stepper.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function Stepper(props) {
key: index, // eslint-disable-line react/no-array-index-key
...state,
}),
React.cloneElement(step, { ...controlProps, ...step.props, ...state }),
React.cloneElement(step, { ...controlProps, ...state, ...step.props }),
];
});

Expand Down
13 changes: 13 additions & 0 deletions packages/material-ui/src/Stepper/Stepper.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,17 @@ describe('<Stepper />', () => {
);
assert.strictEqual(wrapper.find(Step).length, 1);
});

it('should be able to force a state', () => {
const wrapper = shallow(
<Stepper>
<Step className="child-0" />
<Step className="child-1" active />
<Step className="child-2" />
</Stepper>,
);
assert.strictEqual(wrapper.find('.child-0').props().active, true);
assert.strictEqual(wrapper.find('.child-1').props().active, true);
assert.strictEqual(wrapper.find('.child-2').props().active, false);
});
});

0 comments on commit 9085831

Please sign in to comment.