Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(material/tooltip): Remove use of zone onStable for overlay positioning #28668

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading