@@ -39,10 +39,12 @@ import {Directionality} from '@angular/cdk/bidi';
3939import {
4040 ConnectedPosition ,
4141 ConnectionPositionPair ,
42+ createFlexibleConnectedPositionStrategy ,
43+ createOverlayRef ,
44+ createRepositionScrollStrategy ,
4245 FlexibleConnectedPositionStrategy ,
4346 HorizontalConnectionPos ,
4447 OriginConnectionPosition ,
45- Overlay ,
4648 OverlayConnectionPosition ,
4749 OverlayRef ,
4850 ScrollDispatcher ,
@@ -82,8 +84,8 @@ export const MAT_TOOLTIP_SCROLL_STRATEGY = new InjectionToken<() => ScrollStrate
8284 {
8385 providedIn : 'root' ,
8486 factory : ( ) => {
85- const overlay = inject ( Overlay ) ;
86- return ( ) => overlay . scrollStrategies . reposition ( { scrollThrottle : SCROLL_THROTTLE_MS } ) ;
87+ const injector = inject ( Injector ) ;
88+ return ( ) => createRepositionScrollStrategy ( injector , { scrollThrottle : SCROLL_THROTTLE_MS } ) ;
8789 } ,
8890 } ,
8991) ;
@@ -93,8 +95,9 @@ export const MAT_TOOLTIP_SCROLL_STRATEGY = new InjectionToken<() => ScrollStrate
9395 * @deprecated No longer used, will be removed.
9496 * @breaking -change 21.0.0
9597 */
96- export function MAT_TOOLTIP_SCROLL_STRATEGY_FACTORY ( overlay : Overlay ) : ( ) => ScrollStrategy {
97- return ( ) => overlay . scrollStrategies . reposition ( { scrollThrottle : SCROLL_THROTTLE_MS } ) ;
98+ export function MAT_TOOLTIP_SCROLL_STRATEGY_FACTORY ( _overlay : unknown ) : ( ) => ScrollStrategy {
99+ const injector = inject ( Injector ) ;
100+ return ( ) => createRepositionScrollStrategy ( injector , { scrollThrottle : SCROLL_THROTTLE_MS } ) ;
98101}
99102
100103/**
@@ -104,7 +107,7 @@ export function MAT_TOOLTIP_SCROLL_STRATEGY_FACTORY(overlay: Overlay): () => Scr
104107 */
105108export const MAT_TOOLTIP_SCROLL_STRATEGY_FACTORY_PROVIDER = {
106109 provide : MAT_TOOLTIP_SCROLL_STRATEGY ,
107- deps : [ Overlay ] ,
110+ deps : [ ] as any [ ] ,
108111 useFactory : MAT_TOOLTIP_SCROLL_STRATEGY_FACTORY ,
109112} ;
110113
@@ -525,13 +528,13 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
525528 . get ( ScrollDispatcher )
526529 . getAncestorScrollContainers ( this . _elementRef ) ;
527530
528- const overlay = this . _injector . get ( Overlay ) ;
529531 const panelClass = `${ this . _cssClassPrefix } -${ PANEL_CLASS } ` ;
530532
531533 // Create connected position strategy that listens for scroll events to reposition.
532- const strategy = overlay
533- . position ( )
534- . flexibleConnectedTo ( this . positionAtOrigin ? origin || this . _elementRef : this . _elementRef )
534+ const strategy = createFlexibleConnectedPositionStrategy (
535+ this . _injector ,
536+ this . positionAtOrigin ? origin || this . _elementRef : this . _elementRef ,
537+ )
535538 . withTransformOriginOn ( `.${ this . _cssClassPrefix } -tooltip` )
536539 . withFlexibleDimensions ( false )
537540 . withViewportMargin ( this . _viewportMargin )
@@ -549,7 +552,7 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
549552 }
550553 } ) ;
551554
552- this . _overlayRef = overlay . create ( {
555+ this . _overlayRef = createOverlayRef ( this . _injector , {
553556 direction : this . _dir ,
554557 positionStrategy : strategy ,
555558 panelClass : this . _overlayPanelClass ? [ ...this . _overlayPanelClass , panelClass ] : panelClass ,
0 commit comments