Skip to content

Commit 68b267d

Browse files
authored
fix(material/tooltip): regression when injecting ViewContainerRef (#30500)
#30440 deferred the injection of some dependencies in the tooltip, including `ViewContainerRef`. This is problematic, because the act of injecting `ViewContainerRef` changes the shape of some internal data structures in the framework's runtime. As a result, hovering over a tooltip that has been hydrated will throw a runtime error because the structure from the server no longer matches the structure on the client. Fixes #30498.
1 parent 190a433 commit 68b267d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/material/tooltip/tooltip.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
194194
private _focusMonitor = inject(FocusMonitor);
195195
protected _dir = inject(Directionality);
196196
private _injector = inject(Injector);
197+
private _viewContainerRef = inject(ViewContainerRef);
197198
private _defaultOptions = inject<MatTooltipDefaultOptions>(MAT_TOOLTIP_DEFAULT_OPTIONS, {
198199
optional: true,
199200
});
@@ -455,8 +456,7 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
455456
const overlayRef = this._createOverlay(origin);
456457
this._detach();
457458
this._portal =
458-
this._portal ||
459-
new ComponentPortal(this._tooltipComponent, this._injector.get(ViewContainerRef));
459+
this._portal || new ComponentPortal(this._tooltipComponent, this._viewContainerRef);
460460
const instance = (this._tooltipInstance = overlayRef.attach(this._portal).instance);
461461
instance._triggerElement = this._elementRef.nativeElement;
462462
instance._mouseLeaveHideDelay = this._hideDelay;

0 commit comments

Comments
 (0)