Skip to content

Commit def06c1

Browse files
author
mmart1n
committed
feat(stepper): activate step initially
1 parent d1ae4be commit def06c1

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

Diff for: projects/igniteui-angular/src/lib/stepper/stepper.component.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { CommonModule } from '@angular/common';
33
import {
44
AfterViewInit, Component, HostBinding, OnDestroy, OnInit,
55
Input, Output, EventEmitter, ContentChildren, QueryList, ElementRef,
6-
NgModule, OnChanges, SimpleChanges, TemplateRef, ContentChild
6+
NgModule, OnChanges, SimpleChanges, TemplateRef, ContentChild, AfterContentInit
77
} from '@angular/core';
88
import { Subject } from 'rxjs';
99
import { takeUntil } from 'rxjs/operators';
@@ -60,7 +60,7 @@ import { IgxStepperService } from './stepper.service';
6060
{ provide: IGX_STEPPER_COMPONENT, useExisting: IgxStepperComponent },
6161
]
6262
})
63-
export class IgxStepperComponent extends IgxCarouselComponentBase implements OnInit, OnChanges, AfterViewInit, OnDestroy {
63+
export class IgxStepperComponent extends IgxCarouselComponentBase implements OnInit, OnChanges, AfterContentInit, AfterViewInit, OnDestroy {
6464

6565
/** @hidden @internal **/
6666
@HostBinding('class.igx-stepper')
@@ -317,6 +317,14 @@ export class IgxStepperComponent extends IgxCarouselComponentBase implements OnI
317317
});
318318
}
319319

320+
/** @hidden @internal */
321+
public ngAfterContentInit() {
322+
const activeStep = this.steps.find(s => s.active);
323+
if (!activeStep && this.steps[0]) {
324+
this.steps[0].active = true;
325+
}
326+
}
327+
320328
/** @hidden @internal */
321329
public ngAfterViewInit() {
322330
this._steps.changes.pipe(takeUntil(this.destroy$)).subscribe(() => {

Diff for: src/app/stepper/stepper.sample.html

+6-5
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
<igx-icon>check</igx-icon>
3939
</ng-template> -->
4040

41-
<igx-step [active]="true" #step (activeChange)="activeStepChange($event)"
42-
[isValid]="form1.form.valid || form1.form.pristine" [completed]="form1.form.valid && stepper.linear">
41+
<igx-step #step (activeChange)="activeStepChange($event)" [isValid]="form1.form.valid || form1.form.pristine"
42+
[completed]="form1.form.valid && stepper.linear">
4343
<igx-icon igxStepIndicator>face</igx-icon>
4444

4545
<span igxStepTitle>Step No 0</span>
@@ -69,17 +69,18 @@
6969
<span igxStepTitle>Step No 1</span>
7070
<span igxStepSubTitle>Step SubTitle</span>
7171
<div igxStepContent class="sample-body">
72-
Lorem ipsum dolor sit amet consectetur adipisicing elit. Cum eos asperiores, doloribus reiciendis, esse earum, iusto expedita rem quo mollitia voluptatem quas saepe quia! Rem illum quo officia eum quisquam?
72+
Lorem ipsum dolor sit amet consectetur adipisicing elit. Cum eos asperiores, doloribus reiciendis, esse
73+
earum, iusto expedita rem quo mollitia voluptatem quas saepe quia! Rem illum quo officia eum quisquam?
7374
</div>
7475
</igx-step>
7576

76-
<igx-step #step2 (activeChange)="activeStepChange($event)"
77+
<igx-step #step2 [active]="true" (activeChange)="activeStepChange($event)"
7778
[isValid]="form2.form.valid || form2.form.pristine" [completed]="form2.form.valid && stepper.linear">
7879

7980
<div igxStepIndicator>
8081
<div class="avatar-indicator">
8182
<igx-avatar src="https://www.infragistics.com/angular-demos/assets/images/men/1.jpg"
82-
[roundShape]="true"></igx-avatar>
83+
[roundShape]="true"></igx-avatar>
8384
<igx-badge icon="check" type="success"></igx-badge>
8485
</div>
8586
</div>

0 commit comments

Comments
 (0)