Skip to content

Commit 0cce35f

Browse files
mitchellwillsmmalerba
authored andcommitted
fix(stepper): Fix visual flake in focusing stepper header
When the step is changed through a button click sometimes the focus of the new step header is attributed by focus monitor to 'mouse' instead of 'program'. This results in a visual difference in the step header (focus background is missing). Instead, when focusing the step header focus it via 'program' explicitly through the focus monitor.
1 parent 07a16de commit 0cce35f

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/material/stepper/step-header.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ export class MatStepHeader extends CdkStepHeader implements OnDestroy {
8181
this._focusMonitor.stopMonitoring(this._elementRef);
8282
}
8383

84+
/** Focuses the step header. */
85+
focus() {
86+
this._focusMonitor.focusVia(this._elementRef, 'program');
87+
}
88+
8489
/** Returns string label of given step if it is a text label. */
8590
_stringLabel(): string | null {
8691
return this.label instanceof MatStepLabel ? null : this.label;

tools/public_api_guard/material/stepper.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export declare class MatStepHeader extends CdkStepHeader implements OnDestroy {
3535
_getIconContext(): MatStepperIconContext;
3636
_stringLabel(): string | null;
3737
_templateLabel(): MatStepLabel | null;
38+
focus(): void;
3839
ngOnDestroy(): void;
3940
}
4041

0 commit comments

Comments
 (0)