From 8b5c0f12c823a16bdf3d4bcd767d0c42c6b0e870 Mon Sep 17 00:00:00 2001 From: Mitchell Wills Date: Thu, 25 Apr 2019 09:42:54 -0700 Subject: [PATCH] fix(stepper): Fix visual flake in focusing stepper header (#15870) 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. --- src/material/stepper/step-header.ts | 5 +++++ tools/public_api_guard/material/stepper.d.ts | 1 + 2 files changed, 6 insertions(+) diff --git a/src/material/stepper/step-header.ts b/src/material/stepper/step-header.ts index 83006d75899..afaf68f0ee5 100644 --- a/src/material/stepper/step-header.ts +++ b/src/material/stepper/step-header.ts @@ -81,6 +81,11 @@ export class MatStepHeader extends CdkStepHeader implements OnDestroy { this._focusMonitor.stopMonitoring(this._elementRef); } + /** Focuses the step header. */ + focus() { + this._focusMonitor.focusVia(this._elementRef, 'program'); + } + /** Returns string label of given step if it is a text label. */ _stringLabel(): string | null { return this.label instanceof MatStepLabel ? null : this.label; diff --git a/tools/public_api_guard/material/stepper.d.ts b/tools/public_api_guard/material/stepper.d.ts index a96b7f9186a..03db5719024 100644 --- a/tools/public_api_guard/material/stepper.d.ts +++ b/tools/public_api_guard/material/stepper.d.ts @@ -35,6 +35,7 @@ export declare class MatStepHeader extends CdkStepHeader implements OnDestroy { _getIconContext(): MatStepperIconContext; _stringLabel(): string | null; _templateLabel(): MatStepLabel | null; + focus(): void; ngOnDestroy(): void; }