5
5
* Use of this source code is governed by an MIT-style license that can be
6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
- import { take , takeUntil } from 'rxjs/operators' ;
8
+ import { takeUntil } from 'rxjs/operators' ;
9
9
import {
10
10
BooleanInput ,
11
11
coerceBooleanProperty ,
@@ -31,6 +31,8 @@ import {
31
31
ViewEncapsulation ,
32
32
inject ,
33
33
ANIMATION_MODULE_TYPE ,
34
+ afterNextRender ,
35
+ Injector ,
34
36
} from '@angular/core' ;
35
37
import { DOCUMENT , NgClass } from '@angular/common' ;
36
38
import { normalizePassiveListenerOptions , Platform } from '@angular/cdk/platform' ;
@@ -351,6 +353,8 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
351
353
/** Emits when the component is destroyed. */
352
354
private readonly _destroyed = new Subject < void > ( ) ;
353
355
356
+ private _injector = inject ( Injector ) ;
357
+
354
358
constructor (
355
359
private _overlay : Overlay ,
356
360
private _elementRef : ElementRef < HTMLElement > ,
@@ -678,11 +682,16 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
678
682
this . _tooltipInstance . message = this . message ;
679
683
this . _tooltipInstance . _markForCheck ( ) ;
680
684
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
+ ) ;
686
695
}
687
696
}
688
697
0 commit comments