Skip to content

Commit 481f71f

Browse files
authored
fix(material/stepper): strong focus indicator not working for below label position (#22696)
The strong focus indicator renders using a `::before` selector which is also used for styling a stepper header with a `below` label position. This results in broken styles when strong focus indication is enabled. These changes move the indicator to a different element. Fixes #22677.
1 parent 7cd084d commit 481f71f

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

src/material/core/focus-indicators/_focus-indicators.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@
7171
// focused.
7272
.mat-calendar-body-cell:focus .mat-focus-indicator::before,
7373

74+
// Stepper headers have the focus indicator as a descendant,
75+
// because `::before` is used for other styling.
76+
.mat-step-header:focus .mat-focus-indicator::before,
77+
7478
// For all other components, render the focus indicator on focus.
7579
.mat-focus-indicator:focus::before {
7680
content: '';

src/material/stepper/step-header.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="mat-step-header-ripple" matRipple
1+
<div class="mat-step-header-ripple mat-focus-indicator" matRipple
22
[matRippleTrigger]="_getHostElement()"
33
[matRippleDisabled]="disableRipple"></div>
44

src/material/stepper/step-header.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const _MatStepHeaderMixinBase: CanColorCtor & typeof MatStepHeaderBase =
4343
styleUrls: ['step-header.css'],
4444
inputs: ['color'],
4545
host: {
46-
'class': 'mat-step-header mat-focus-indicator',
46+
'class': 'mat-step-header',
4747
'role': 'tab',
4848
},
4949
encapsulation: ViewEncapsulation.None,

src/material/stepper/stepper.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ describe('MatStepper', () => {
392392
[...fixture.debugElement.nativeElement.querySelectorAll('.mat-vertical-stepper-header')];
393393

394394
expect(stepHeaderNativeElements
395-
.every(element => element.classList.contains('mat-focus-indicator'))).toBe(true);
395+
.every(element => element.querySelector('.mat-focus-indicator'))).toBe(true);
396396
});
397397

398398
});

0 commit comments

Comments
 (0)