@@ -187,10 +187,7 @@ const MAX_WIDTH = 200;
187
187
} ,
188
188
} )
189
189
export class MatTooltip implements OnDestroy , AfterViewInit {
190
- private _overlay = inject ( Overlay ) ;
191
190
private _elementRef = inject < ElementRef < HTMLElement > > ( ElementRef ) ;
192
- private _scrollDispatcher = inject ( ScrollDispatcher ) ;
193
- private _viewContainerRef = inject ( ViewContainerRef ) ;
194
191
private _ngZone = inject ( NgZone ) ;
195
192
private _platform = inject ( Platform ) ;
196
193
private _ariaDescriber = inject ( AriaDescriber ) ;
@@ -209,7 +206,6 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
209
206
private _positionAtOrigin : boolean = false ;
210
207
private _disabled : boolean = false ;
211
208
private _tooltipClass : string | string [ ] | Set < string > | { [ key : string ] : any } ;
212
- private _scrollStrategy = inject ( MAT_TOOLTIP_SCROLL_STRATEGY ) ;
213
209
private _viewInitialized = false ;
214
210
private _pointerExitEventsInitialized = false ;
215
211
private readonly _tooltipComponent = TooltipComponent ;
@@ -362,9 +358,6 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
362
358
private readonly _passiveListeners : ( readonly [ string , EventListenerOrEventListenerObject ] ) [ ] =
363
359
[ ] ;
364
360
365
- /** Reference to the current document. */
366
- private _document = inject ( DOCUMENT ) ;
367
-
368
361
/** Timer started at the last `touchstart` event. */
369
362
private _touchstartTimeout : null | ReturnType < typeof setTimeout > = null ;
370
363
@@ -462,7 +455,7 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
462
455
const overlayRef = this . _createOverlay ( origin ) ;
463
456
this . _detach ( ) ;
464
457
this . _portal =
465
- this . _portal || new ComponentPortal ( this . _tooltipComponent , this . _viewContainerRef ) ;
458
+ this . _portal || new ComponentPortal ( this . _tooltipComponent , this . _injector . get ( ViewContainerRef ) ) ;
466
459
const instance = ( this . _tooltipInstance = overlayRef . attach ( this . _portal ) . instance ) ;
467
460
instance . _triggerElement = this . _elementRef . nativeElement ;
468
461
instance . _mouseLeaveHideDelay = this . _hideDelay ;
@@ -512,12 +505,14 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
512
505
this . _detach ( ) ;
513
506
}
514
507
515
- const scrollableAncestors = this . _scrollDispatcher . getAncestorScrollContainers (
508
+ const scrollableAncestors = this . _injector . get ( ScrollDispatcher ) . getAncestorScrollContainers (
516
509
this . _elementRef ,
517
510
) ;
518
511
512
+ const overlay = this . _injector . get ( Overlay ) ;
513
+
519
514
// Create connected position strategy that listens for scroll events to reposition.
520
- const strategy = this . _overlay
515
+ const strategy = overlay
521
516
. position ( )
522
517
. flexibleConnectedTo ( this . positionAtOrigin ? origin || this . _elementRef : this . _elementRef )
523
518
. withTransformOriginOn ( `.${ this . _cssClassPrefix } -tooltip` )
@@ -537,11 +532,11 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
537
532
}
538
533
} ) ;
539
534
540
- this . _overlayRef = this . _overlay . create ( {
535
+ this . _overlayRef = overlay . create ( {
541
536
direction : this . _dir ,
542
537
positionStrategy : strategy ,
543
538
panelClass : `${ this . _cssClassPrefix } -${ PANEL_CLASS } ` ,
544
- scrollStrategy : this . _scrollStrategy ( ) ,
539
+ scrollStrategy : this . _injector . get ( MAT_TOOLTIP_SCROLL_STRATEGY ) ( ) ,
545
540
} ) ;
546
541
547
542
this . _updatePosition ( this . _overlayRef ) ;
@@ -874,7 +869,7 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
874
869
/** Listener for the `wheel` event on the element. */
875
870
private _wheelListener ( event : WheelEvent ) {
876
871
if ( this . _isTooltipVisible ( ) ) {
877
- const elementUnderPointer = this . _document . elementFromPoint ( event . clientX , event . clientY ) ;
872
+ const elementUnderPointer = this . _injector . get ( DOCUMENT ) . elementFromPoint ( event . clientX , event . clientY ) ;
878
873
const element = this . _elementRef . nativeElement ;
879
874
880
875
// On non-touch devices we depend on the `mouseleave` event to close the tooltip, but it
0 commit comments