Skip to content

Commit 3e91f91

Browse files
authored
refactor(material/tooltip): Remove use of zone onStable for overlay positioning (#28668)
1 parent e524567 commit 3e91f91

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/material/tooltip/tooltip.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
import {take, takeUntil} from 'rxjs/operators';
8+
import {takeUntil} from 'rxjs/operators';
99
import {
1010
BooleanInput,
1111
coerceBooleanProperty,
@@ -31,6 +31,8 @@ import {
3131
ViewEncapsulation,
3232
inject,
3333
ANIMATION_MODULE_TYPE,
34+
afterNextRender,
35+
Injector,
3436
} from '@angular/core';
3537
import {DOCUMENT, NgClass} from '@angular/common';
3638
import {normalizePassiveListenerOptions, Platform} from '@angular/cdk/platform';
@@ -351,6 +353,8 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
351353
/** Emits when the component is destroyed. */
352354
private readonly _destroyed = new Subject<void>();
353355

356+
private _injector = inject(Injector);
357+
354358
constructor(
355359
private _overlay: Overlay,
356360
private _elementRef: ElementRef<HTMLElement>,
@@ -678,11 +682,16 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
678682
this._tooltipInstance.message = this.message;
679683
this._tooltipInstance._markForCheck();
680684

681-
this._ngZone.onMicrotaskEmpty.pipe(take(1), takeUntil(this._destroyed)).subscribe(() => {
682-
if (this._tooltipInstance) {
683-
this._overlayRef!.updatePosition();
684-
}
685-
});
685+
afterNextRender(
686+
() => {
687+
if (this._tooltipInstance) {
688+
this._overlayRef!.updatePosition();
689+
}
690+
},
691+
{
692+
injector: this._injector,
693+
},
694+
);
686695
}
687696
}
688697

0 commit comments

Comments
 (0)