Skip to content

Commit

Permalink
refactor(cdk): add tuiZonefreeScheduler to default handler (#8740)
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode authored Aug 29, 2024
1 parent 59c9009 commit 8f6706b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion projects/cdk/directives/auto-focus/autofocus.options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
},
];
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -11,6 +12,7 @@ export class TuiDefaultAutofocusHandler extends AbstractTuiAutofocusHandler {
constructor(
el: ElementRef<HTMLElement>,
private readonly animationFrame$: Observable<number>,
private readonly zone: NgZone,
) {
super(el);
}
Expand All @@ -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),
Expand Down

0 comments on commit 8f6706b

Please sign in to comment.