diff --git a/projects/cdk/directives/auto-focus/autofocus.options.ts b/projects/cdk/directives/auto-focus/autofocus.options.ts index b5060f5f60b4..3631ae9ad292 100644 --- a/projects/cdk/directives/auto-focus/autofocus.options.ts +++ b/projects/cdk/directives/auto-focus/autofocus.options.ts @@ -49,7 +49,7 @@ export const TUI_AUTOFOCUS_PROVIDERS = [ ) => isIos ? new TuiIosAutofocusHandler(el, renderer, zone, win) - : new TuiDefaultAutofocusHandler(el, animationFrame$), + : new TuiDefaultAutofocusHandler(el, animationFrame$, zone), deps: [ElementRef, WA_ANIMATION_FRAME, Renderer2, NgZone, WA_WINDOW, TUI_IS_IOS], }, ]; diff --git a/projects/cdk/directives/auto-focus/handlers/default.handler.ts b/projects/cdk/directives/auto-focus/handlers/default.handler.ts index 2b725b161f35..505a4825a829 100644 --- a/projects/cdk/directives/auto-focus/handlers/default.handler.ts +++ b/projects/cdk/directives/auto-focus/handlers/default.handler.ts @@ -1,4 +1,5 @@ -import type {ElementRef} from '@angular/core'; +import type {ElementRef, NgZone} from '@angular/core'; +import {tuiZonefreeScheduler} from '@taiga-ui/cdk/observables'; import type {Observable} from 'rxjs'; import {map, race, skipWhile, take, throttleTime, timer} from 'rxjs'; @@ -11,6 +12,7 @@ export class TuiDefaultAutofocusHandler extends AbstractTuiAutofocusHandler { constructor( el: ElementRef, private readonly animationFrame$: Observable, + private readonly zone: NgZone, ) { super(el); } @@ -20,7 +22,7 @@ export class TuiDefaultAutofocusHandler extends AbstractTuiAutofocusHandler { race( timer(TIMEOUT), this.animationFrame$.pipe( - throttleTime(100), + throttleTime(100, tuiZonefreeScheduler(this.zone)), map(() => this.element.closest(NG_ANIMATION_SELECTOR)), skipWhile(Boolean), take(1),