fix(stepper): selected is always undefined (#7213)

This commit is contained in:
NothingEverHappens
2017-09-29 16:07:35 -04:00
committed by Andrew Seguin
parent ba5653db20
commit 217840c5b9
2 changed files with 4 additions and 2 deletions
+1 -1
View File
@@ -150,7 +150,7 @@ export class CdkStepper {
/** The step that is selected. */
@Input()
get selected() { return this._steps[this.selectedIndex]; }
get selected() { return this._steps.toArray()[this.selectedIndex]; }
set selected(step: CdkStep) {
this.selectedIndex = this._steps.toArray().indexOf(step);
}
+3 -1
View File
@@ -10,7 +10,6 @@ import {MatStepperModule} from './index';
import {MatHorizontalStepper, MatStepper, MatVerticalStepper} from './stepper';
import {MatStepperNext, MatStepperPrevious} from './stepper-button';
const VALID_REGEX = /valid/;
describe('MatHorizontalStepper', () => {
@@ -307,6 +306,7 @@ function assertSelectionChangeOnHeaderClick(fixture: ComponentFixture<any>,
let stepperComponent = fixture.debugElement.query(By.directive(MatStepper)).componentInstance;
expect(stepperComponent.selectedIndex).toBe(0);
expect(stepperComponent.selected instanceof MdStep).toBe(true);
// select the second step
let stepHeaderEl = stepHeaders[1].nativeElement;
@@ -314,6 +314,7 @@ function assertSelectionChangeOnHeaderClick(fixture: ComponentFixture<any>,
fixture.detectChanges();
expect(stepperComponent.selectedIndex).toBe(1);
expect(stepperComponent.selected instanceof MdStep).toBe(true);
// select the third step
stepHeaderEl = stepHeaders[2].nativeElement;
@@ -321,6 +322,7 @@ function assertSelectionChangeOnHeaderClick(fixture: ComponentFixture<any>,
fixture.detectChanges();
expect(stepperComponent.selectedIndex).toBe(2);
expect(stepperComponent.selected instanceof MdStep).toBe(true);
}
/** Asserts that 'aria-expanded' attribute is correct for expanded content of step. */