Skip to content

Commit 217840c

Browse files
NothingEverHappensandrewseguin
authored andcommitted
fix(stepper): selected is always undefined (#7213)
1 parent ba5653d commit 217840c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/cdk/stepper/stepper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export class CdkStepper {
150150

151151
/** The step that is selected. */
152152
@Input()
153-
get selected() { return this._steps[this.selectedIndex]; }
153+
get selected() { return this._steps.toArray()[this.selectedIndex]; }
154154
set selected(step: CdkStep) {
155155
this.selectedIndex = this._steps.toArray().indexOf(step);
156156
}

src/lib/stepper/stepper.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {MatStepperModule} from './index';
1010
import {MatHorizontalStepper, MatStepper, MatVerticalStepper} from './stepper';
1111
import {MatStepperNext, MatStepperPrevious} from './stepper-button';
1212

13-
1413
const VALID_REGEX = /valid/;
1514

1615
describe('MatHorizontalStepper', () => {
@@ -307,20 +306,23 @@ function assertSelectionChangeOnHeaderClick(fixture: ComponentFixture<any>,
307306
let stepperComponent = fixture.debugElement.query(By.directive(MatStepper)).componentInstance;
308307

309308
expect(stepperComponent.selectedIndex).toBe(0);
309+
expect(stepperComponent.selected instanceof MdStep).toBe(true);
310310

311311
// select the second step
312312
let stepHeaderEl = stepHeaders[1].nativeElement;
313313
stepHeaderEl.click();
314314
fixture.detectChanges();
315315

316316
expect(stepperComponent.selectedIndex).toBe(1);
317+
expect(stepperComponent.selected instanceof MdStep).toBe(true);
317318

318319
// select the third step
319320
stepHeaderEl = stepHeaders[2].nativeElement;
320321
stepHeaderEl.click();
321322
fixture.detectChanges();
322323

323324
expect(stepperComponent.selectedIndex).toBe(2);
325+
expect(stepperComponent.selected instanceof MdStep).toBe(true);
324326
}
325327

326328
/** Asserts that 'aria-expanded' attribute is correct for expanded content of step. */

0 commit comments

Comments
 (0)