From b38b966b925b95e62b674012c2951f93737d02c7 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Thu, 5 Apr 2018 17:04:43 +0200 Subject: [PATCH] fix(focus-monitor): hitting ngzone when using focusVia (#10608) Currently most of the timeouts inside the `FocusMonitor` are run outside the `NgZone`, because they're called from event listeners that are bound on the outside, however the one from `_setOriginForCurrentEventQueue` can still end up inside when it's called by `focusVia`. --- src/cdk/a11y/focus-monitor/focus-monitor.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cdk/a11y/focus-monitor/focus-monitor.ts b/src/cdk/a11y/focus-monitor/focus-monitor.ts index e0ef27bf4f2..87b39f3cffd 100644 --- a/src/cdk/a11y/focus-monitor/focus-monitor.ts +++ b/src/cdk/a11y/focus-monitor/focus-monitor.ts @@ -240,8 +240,10 @@ export class FocusMonitor implements OnDestroy { * @param origin The origin to set. */ private _setOriginForCurrentEventQueue(origin: FocusOrigin): void { - this._origin = origin; - this._originTimeoutId = setTimeout(() => this._origin = null, 0); + this._ngZone.runOutsideAngular(() => { + this._origin = origin; + this._originTimeoutId = setTimeout(() => this._origin = null, 0); + }); } /**