mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
fix(stepper): selected is always undefined (#7213)
This commit is contained in:
committed by
Andrew Seguin
parent
ba5653db20
commit
217840c5b9
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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. */
|
||||
|
||||
Reference in New Issue
Block a user