Skip to content

Commit 967f0f1

Browse files
fix(stepper): prevent step indicator from shrinking with long titles - 20.1.x (#16820)
1 parent e9ef1ff commit 967f0f1

2 files changed

Lines changed: 49 additions & 5 deletions

File tree

projects/igniteui-angular/src/lib/core/styles/components/stepper/_stepper-theme.scss

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@
203203
font-size: rem(12px);
204204
height: $indicator-size;
205205
width: $indicator-size;
206+
min-width: $indicator-size;
206207
white-space: nowrap;
207208
border-radius: var-get($theme, 'border-radius-indicator');
208209
color: var-get($theme, 'indicator-color');
@@ -633,10 +634,6 @@
633634

634635
%igx-stepper__step--start,
635636
%igx-stepper__step--end {
636-
%igx-stepper__step-indicator {
637-
flex: 1 0 auto;
638-
}
639-
640637
%igx-stepper__step-header {
641638
@if $variant != 'fluent' {
642639
padding: calc(#{$step-header-padding} / 2);

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

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ describe('Rendering Tests', () => {
8383
imports: [
8484
NoopAnimationsModule,
8585
IgxStepperSampleTestComponent,
86-
IgxStepperLinearComponent
86+
IgxStepperLinearComponent,
87+
IgxStepperIndicatorNoShrinkComponent
8788
]
8889
}).compileComponents();
8990
})
@@ -720,6 +721,23 @@ describe('Rendering Tests', () => {
720721
stepper.horizontalAnimationType = 'fade';
721722
testAnimationBehavior('fade', fix, false);
722723
}));
724+
725+
it('should not shrink the step indicator in vertical orientation when titlePosition="end" and the title is very long', fakeAsync(() => {
726+
const fixture = TestBed.createComponent(IgxStepperIndicatorNoShrinkComponent);
727+
fixture.detectChanges();
728+
tick();
729+
730+
const stepperInstance = fixture.componentInstance.stepper;
731+
const indicator = stepperInstance.steps[0].nativeElement.querySelector(`.${STEP_INDICATOR_CLASS}`) as HTMLElement;
732+
733+
const { minWidth } = getComputedStyle(indicator);
734+
const { width, height } = indicator.getBoundingClientRect();
735+
736+
expect(minWidth).not.toBe('0px');
737+
expect(minWidth).not.toBe('auto');
738+
expect(Math.abs(width - height)).toBeLessThan(1.5);
739+
expect(Math.abs(width - parseFloat(minWidth))).toBeLessThan(1.5);
740+
}));
723741
});
724742

725743
describe('Keyboard navigation', () => {
@@ -1358,3 +1376,32 @@ export class IgxStepperSampleTestComponent {
13581376
export class IgxStepperLinearComponent {
13591377
@ViewChild(IgxStepperComponent) public stepper: IgxStepperComponent;
13601378
}
1379+
1380+
@Component({
1381+
template: `
1382+
<div>
1383+
<igx-stepper #stepper [orientation]="'vertical'" [titlePosition]="'end'">
1384+
<igx-step [active]="true">
1385+
<span igxStepTitle>{{ longTitle }}</span>
1386+
<div igxStepContent>Content</div>
1387+
</igx-step>
1388+
<igx-step>
1389+
<span igxStepTitle>Short</span>
1390+
<div igxStepContent>Content</div>
1391+
</igx-step>
1392+
</igx-stepper>
1393+
</div>
1394+
`,
1395+
imports: [
1396+
IgxStepperComponent,
1397+
IgxStepComponent,
1398+
IgxStepTitleDirective,
1399+
IgxStepContentDirective
1400+
]
1401+
})
1402+
export class IgxStepperIndicatorNoShrinkComponent {
1403+
@ViewChild(IgxStepperComponent) public stepper: IgxStepperComponent;
1404+
1405+
public longTitle =
1406+
'This is a very very very very very very very very very very very very very very very very very very very very very long step title that should not shrink the indicator';
1407+
}

0 commit comments

Comments
 (0)