Skip to content

Commit

Permalink
[Stepper] We were too greedy, revert (#13192)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari authored Oct 10, 2018
1 parent 9085831 commit d458811
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/material-ui/src/Step/Step.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface StepProps
connector?: React.ReactElement<any>;
disabled?: boolean;
index?: number;
last?: boolean;
orientation?: Orientation;
}

Expand Down
6 changes: 6 additions & 0 deletions packages/material-ui/src/Step/Step.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function Step(props) {
connector,
disabled,
index,
last,
orientation,
...other
} = props;
Expand Down Expand Up @@ -85,6 +86,7 @@ function Step(props) {
alternativeLabel,
completed,
disabled,
last,
icon: index + 1,
orientation,
...child.props,
Expand Down Expand Up @@ -136,6 +138,10 @@ Step.propTypes = {
* Used internally for numbering.
*/
index: PropTypes.number,
/**
* @ignore
*/
last: PropTypes.bool,
/**
* @ignore
*/
Expand Down
6 changes: 6 additions & 0 deletions packages/material-ui/src/StepLabel/StepLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ function StepLabel(props) {
disabled,
error,
icon,
last,
optional,
orientation,
StepIconComponent: StepIconComponentProp,
Expand Down Expand Up @@ -177,6 +178,10 @@ StepLabel.propTypes = {
* Override the default icon.
*/
icon: PropTypes.node,
/**
* @ignore
*/
last: PropTypes.bool,
/**
* The optional node to display.
*/
Expand All @@ -201,6 +206,7 @@ StepLabel.defaultProps = {
completed: false,
disabled: false,
error: false,
last: false,
orientation: 'horizontal',
};

Expand Down
3 changes: 2 additions & 1 deletion packages/material-ui/src/Stepper/Stepper.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ function Stepper(props) {
const childrenArray = React.Children.toArray(children);
const steps = childrenArray.map((step, index) => {
const controlProps = {
orientation,
alternativeLabel,
connector: connectorProp,
last: index + 1 === childrenArray.length,
orientation,
};

const state = {
Expand Down
31 changes: 31 additions & 0 deletions packages/material-ui/src/Stepper/Stepper.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import CheckCircle from '../internal/svg-icons/CheckCircle';
import { createShallow, createMount } from '../test-utils';
import Paper from '../Paper';
import Step from '../Step';
import StepLabel from '../StepLabel';
import StepConnector from '../StepConnector';
import StepContent from '../StepContent';
import Stepper from './Stepper';

describe('<Stepper />', () => {
Expand Down Expand Up @@ -212,4 +214,33 @@ describe('<Stepper />', () => {
assert.strictEqual(wrapper.find('.child-1').props().active, true);
assert.strictEqual(wrapper.find('.child-2').props().active, false);
});

it('should hide the last connector', () => {
const wrapper = mount(
<Stepper orientation="vertical">
<Step>
<StepLabel>one</StepLabel>
<StepContent />
</Step>
<Step>
<StepLabel>two</StepLabel>
<StepContent />
</Step>
</Stepper>,
);
assert.strictEqual(
wrapper
.find(StepContent)
.at(0)
.props().last,
false,
);
assert.strictEqual(
wrapper
.find(StepContent)
.at(1)
.props().last,
true,
);
});
});

0 comments on commit d458811

Please sign in to comment.