@@ -12,8 +12,10 @@ import {DOWN_ARROW, ENTER, ESCAPE, TAB, UP_ARROW, hasModifierKey} from '@angular
12
12
import { BreakpointObserver , Breakpoints } from '@angular/cdk/layout' ;
13
13
import {
14
14
ConnectedPosition ,
15
+ createFlexibleConnectedPositionStrategy ,
16
+ createOverlayRef ,
17
+ createRepositionScrollStrategy ,
15
18
FlexibleConnectedPositionStrategy ,
16
- Overlay ,
17
19
OverlayConfig ,
18
20
OverlayRef ,
19
21
PositionStrategy ,
@@ -29,6 +31,7 @@ import {
29
31
ElementRef ,
30
32
EnvironmentInjector ,
31
33
InjectionToken ,
34
+ Injector ,
32
35
Input ,
33
36
NgZone ,
34
37
OnChanges ,
@@ -88,8 +91,8 @@ export const MAT_AUTOCOMPLETE_SCROLL_STRATEGY = new InjectionToken<() => ScrollS
88
91
{
89
92
providedIn : 'root' ,
90
93
factory : ( ) => {
91
- const overlay = inject ( Overlay ) ;
92
- return ( ) => overlay . scrollStrategies . reposition ( ) ;
94
+ const injector = inject ( Injector ) ;
95
+ return ( ) => createRepositionScrollStrategy ( injector ) ;
93
96
} ,
94
97
} ,
95
98
) ;
@@ -99,8 +102,9 @@ export const MAT_AUTOCOMPLETE_SCROLL_STRATEGY = new InjectionToken<() => ScrollS
99
102
* @deprecated No longer used, will be removed.
100
103
* @breaking -change 21.0.0
101
104
*/
102
- export function MAT_AUTOCOMPLETE_SCROLL_STRATEGY_FACTORY ( overlay : Overlay ) : ( ) => ScrollStrategy {
103
- return ( ) => overlay . scrollStrategies . reposition ( ) ;
105
+ export function MAT_AUTOCOMPLETE_SCROLL_STRATEGY_FACTORY ( _overlay : unknown ) : ( ) => ScrollStrategy {
106
+ const injector = inject ( Injector ) ;
107
+ return ( ) => createRepositionScrollStrategy ( injector ) ;
104
108
}
105
109
106
110
/**
@@ -110,7 +114,7 @@ export function MAT_AUTOCOMPLETE_SCROLL_STRATEGY_FACTORY(overlay: Overlay): () =
110
114
*/
111
115
export const MAT_AUTOCOMPLETE_SCROLL_STRATEGY_FACTORY_PROVIDER = {
112
116
provide : MAT_AUTOCOMPLETE_SCROLL_STRATEGY ,
113
- deps : [ Overlay ] ,
117
+ deps : [ ] as any [ ] ,
114
118
useFactory : MAT_AUTOCOMPLETE_SCROLL_STRATEGY_FACTORY ,
115
119
} ;
116
120
@@ -142,7 +146,7 @@ export class MatAutocompleteTrigger
142
146
{
143
147
private _environmentInjector = inject ( EnvironmentInjector ) ;
144
148
private _element = inject < ElementRef < HTMLInputElement > > ( ElementRef ) ;
145
- private _overlay = inject ( Overlay ) ;
149
+ private _injector = inject ( Injector ) ;
146
150
private _viewContainerRef = inject ( ViewContainerRef ) ;
147
151
private _zone = inject ( NgZone ) ;
148
152
private _changeDetectorRef = inject ( ChangeDetectorRef ) ;
@@ -794,7 +798,7 @@ export class MatAutocompleteTrigger
794
798
this . _portal = new TemplatePortal ( this . autocomplete . template , this . _viewContainerRef , {
795
799
id : this . _formField ?. getLabelId ( ) ,
796
800
} ) ;
797
- overlayRef = this . _overlay . create ( this . _getOverlayConfig ( ) ) ;
801
+ overlayRef = createOverlayRef ( this . _injector , this . _getOverlayConfig ( ) ) ;
798
802
this . _overlayRef = overlayRef ;
799
803
this . _viewportSubscription = this . _viewportRuler . change ( ) . subscribe ( ( ) => {
800
804
if ( this . panelOpen && overlayRef ) {
@@ -916,9 +920,10 @@ export class MatAutocompleteTrigger
916
920
917
921
private _getOverlayPosition ( ) : PositionStrategy {
918
922
// Set default Overlay Position
919
- const strategy = this . _overlay
920
- . position ( )
921
- . flexibleConnectedTo ( this . _getConnectedElement ( ) )
923
+ const strategy = createFlexibleConnectedPositionStrategy (
924
+ this . _injector ,
925
+ this . _getConnectedElement ( ) ,
926
+ )
922
927
. withFlexibleDimensions ( false )
923
928
. withPush ( false ) ;
924
929
0 commit comments