Skip to content
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
16 changes: 10 additions & 6 deletions src/material/tooltip/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
private _currentPosition: TooltipPosition;
private readonly _cssClassPrefix: string = 'mat-mdc';
private _ariaDescriptionPending: boolean;
private _dirSubscribed = false;

/** Allows the user to define the position of the tooltip relative to the parent element */
@Input('matTooltipPosition')
Expand Down Expand Up @@ -395,12 +396,6 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
}
}

this._dir.change.pipe(takeUntil(this._destroyed)).subscribe(() => {
if (this._overlayRef) {
this._updatePosition(this._overlayRef);
}
});

this._viewportMargin = MIN_VIEWPORT_TOOLTIP_THRESHOLD;
}

Expand Down Expand Up @@ -567,6 +562,15 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
this._overlayRef.addPanelClass(`${this._cssClassPrefix}-tooltip-panel-non-interactive`);
}

if (!this._dirSubscribed) {
this._dirSubscribed = true;
this._dir.change.pipe(takeUntil(this._destroyed)).subscribe(() => {
if (this._overlayRef) {
this._updatePosition(this._overlayRef);
}
});
}

return this._overlayRef;
}

Expand Down
Loading