Skip to content

Commit c23454d

Browse files
authored
Fix(stepper): Calculate disabled steps when linear mode is set initially (#12929)
* fix(stepper): calculate disabled steps when linear mode is set initially * fix(stepper): add requested changes
1 parent 17e789d commit c23454d

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

projects/igniteui-angular/src/lib/stepper/stepper.component.spec.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ describe('Rendering Tests', () => {
7979
waitForAsync(() => {
8080
TestBed.configureTestingModule({
8181
declarations: [
82-
IgxStepperSampleTestComponent
82+
IgxStepperSampleTestComponent,
83+
IgxStepperLinearComponent
8384
],
8485
imports: [
8586
NoopAnimationsModule,
@@ -148,6 +149,22 @@ describe('Rendering Tests', () => {
148149
expect(serviceCollapseSpy).toHaveBeenCalledOnceWith(stepper.steps[0]);
149150
}));
150151

152+
it('should calculate disabled steps properly when the stepper is initially in linear mode', fakeAsync(()=>{
153+
const fixture = TestBed.createComponent(IgxStepperLinearComponent);
154+
fixture.detectChanges();
155+
const linearStepper = fixture.componentInstance.stepper;
156+
157+
const serviceExpandSpy = spyOn((linearStepper as any).stepperService, 'expand').and.callThrough();
158+
linearStepper.next();
159+
fixture.detectChanges();
160+
tick();
161+
162+
expect(linearStepper.steps[1].active).toBeFalsy();
163+
expect(linearStepper.steps[0].active).toBeTruthy();
164+
expect(linearStepper.steps[1].linearDisabled).toBeTruthy();
165+
expect(serviceExpandSpy).not.toHaveBeenCalled();
166+
}));
167+
151168
it('should not allow moving forward to next step in linear mode if the previous step is invalid', fakeAsync(() => {
152169
const serviceExpandSpy = spyOn((stepper as any).stepperService, 'expand').and.callThrough();
153170
stepper.orientation = IgxStepperOrientation.Horizontal;
@@ -1292,3 +1309,21 @@ export class IgxStepperSampleTestComponent {
12921309
public displayHiddenStep = false;
12931310

12941311
}
1312+
1313+
@Component({
1314+
template: `
1315+
<igx-stepper #stepper [linear]="true">
1316+
<igx-step #step1 [isValid]="false">
1317+
</igx-step>
1318+
1319+
<igx-step #step2 [isValid]="false">
1320+
</igx-step>
1321+
1322+
<igx-step #step3 [isValid]="false">
1323+
</igx-step>
1324+
</igx-stepper>
1325+
`
1326+
})
1327+
export class IgxStepperLinearComponent {
1328+
@ViewChild(IgxStepperComponent) public stepper: IgxStepperComponent;
1329+
}

projects/igniteui-angular/src/lib/stepper/stepper.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,10 @@ export class IgxStepperComponent extends IgxCarouselComponentBase implements Igx
378378
this.activateFirstStep(true);
379379
}
380380

381+
if (this.linear) {
382+
this.stepperService.calculateLinearDisabledSteps();
383+
}
384+
381385
this.handleStepChanges();
382386
}
383387

0 commit comments

Comments
 (0)