Skip to content

Commit

Permalink
refactor(material/tooltip): Remove use of zone onStable for overlay p…
Browse files Browse the repository at this point in the history
…ositioning (#28668)
  • Loading branch information
mmalerba authored Mar 11, 2024
1 parent e524567 commit 3e91f91
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/material/tooltip/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {take, takeUntil} from 'rxjs/operators';
import {takeUntil} from 'rxjs/operators';
import {
BooleanInput,
coerceBooleanProperty,
Expand All @@ -31,6 +31,8 @@ import {
ViewEncapsulation,
inject,
ANIMATION_MODULE_TYPE,
afterNextRender,
Injector,
} from '@angular/core';
import {DOCUMENT, NgClass} from '@angular/common';
import {normalizePassiveListenerOptions, Platform} from '@angular/cdk/platform';
Expand Down Expand Up @@ -351,6 +353,8 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
/** Emits when the component is destroyed. */
private readonly _destroyed = new Subject<void>();

private _injector = inject(Injector);

constructor(
private _overlay: Overlay,
private _elementRef: ElementRef<HTMLElement>,
Expand Down Expand Up @@ -678,11 +682,16 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
this._tooltipInstance.message = this.message;
this._tooltipInstance._markForCheck();

this._ngZone.onMicrotaskEmpty.pipe(take(1), takeUntil(this._destroyed)).subscribe(() => {
if (this._tooltipInstance) {
this._overlayRef!.updatePosition();
}
});
afterNextRender(
() => {
if (this._tooltipInstance) {
this._overlayRef!.updatePosition();
}
},
{
injector: this._injector,
},
);
}
}

Expand Down

0 comments on commit 3e91f91

Please sign in to comment.