@@ -21,8 +21,12 @@ import {
2121 UP_ARROW ,
2222} from '@angular/cdk/keycodes' ;
2323import {
24+ createBlockScrollStrategy ,
25+ createFlexibleConnectedPositionStrategy ,
26+ createGlobalPositionStrategy ,
27+ createOverlayRef ,
28+ createRepositionScrollStrategy ,
2429 FlexibleConnectedPositionStrategy ,
25- Overlay ,
2630 OverlayConfig ,
2731 OverlayRef ,
2832 ScrollStrategy ,
@@ -82,8 +86,8 @@ export const MAT_DATEPICKER_SCROLL_STRATEGY = new InjectionToken<() => ScrollStr
8286 {
8387 providedIn : 'root' ,
8488 factory : ( ) => {
85- const overlay = inject ( Overlay ) ;
86- return ( ) => overlay . scrollStrategies . reposition ( ) ;
89+ const injector = inject ( Injector ) ;
90+ return ( ) => createRepositionScrollStrategy ( injector ) ;
8791 } ,
8892 } ,
8993) ;
@@ -93,8 +97,9 @@ export const MAT_DATEPICKER_SCROLL_STRATEGY = new InjectionToken<() => ScrollStr
9397 * @deprecated No longer used, will be removed.
9498 * @breaking -change 21.0.0
9599 */
96- export function MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY ( overlay : Overlay ) : ( ) => ScrollStrategy {
97- return ( ) => overlay . scrollStrategies . reposition ( ) ;
100+ export function MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY ( _overlay : unknown ) : ( ) => ScrollStrategy {
101+ const injector = inject ( Injector ) ;
102+ return ( ) => createRepositionScrollStrategy ( injector ) ;
98103}
99104
100105/** Possible positions for the datepicker dropdown along the X axis. */
@@ -110,7 +115,7 @@ export type DatepickerDropdownPositionY = 'above' | 'below';
110115 */
111116export const MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY_PROVIDER = {
112117 provide : MAT_DATEPICKER_SCROLL_STRATEGY ,
113- deps : [ Overlay ] ,
118+ deps : [ ] as any [ ] ,
114119 useFactory : MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY ,
115120} ;
116121
@@ -390,7 +395,7 @@ export abstract class MatDatepickerBase<
390395 >
391396 implements MatDatepickerPanel < C , S , D > , OnDestroy , OnChanges
392397{
393- private _overlay = inject ( Overlay ) ;
398+ private _injector = inject ( Injector ) ;
394399 private _viewContainerRef = inject ( ViewContainerRef ) ;
395400 private _dateAdapter = inject < DateAdapter < D > > ( DateAdapter , { optional : true } ) ! ;
396401 private _dir = inject ( Directionality , { optional : true } ) ;
@@ -565,8 +570,6 @@ export abstract class MatDatepickerBase<
565570 /** Emits when the datepicker's state changes. */
566571 readonly stateChanges = new Subject < void > ( ) ;
567572
568- private _injector = inject ( Injector ) ;
569-
570573 private readonly _changeDetectorRef = inject ( ChangeDetectorRef ) ;
571574
572575 constructor ( ...args : unknown [ ] ) ;
@@ -760,7 +763,8 @@ export abstract class MatDatepickerBase<
760763 MatDatepickerContent ,
761764 this . _viewContainerRef ,
762765 ) ;
763- const overlayRef = ( this . _overlayRef = this . _overlay . create (
766+ const overlayRef = ( this . _overlayRef = createOverlayRef (
767+ this . _injector ,
764768 new OverlayConfig ( {
765769 positionStrategy : isDialog ? this . _getDialogStrategy ( ) : this . _getDropdownStrategy ( ) ,
766770 hasBackdrop : true ,
@@ -769,7 +773,9 @@ export abstract class MatDatepickerBase<
769773 this . _backdropHarnessClass ,
770774 ] ,
771775 direction : this . _dir || 'ltr' ,
772- scrollStrategy : isDialog ? this . _overlay . scrollStrategies . block ( ) : this . _scrollStrategy ( ) ,
776+ scrollStrategy : isDialog
777+ ? createBlockScrollStrategy ( this . _injector )
778+ : this . _scrollStrategy ( ) ,
773779 panelClass : `mat-datepicker-${ isDialog ? 'dialog' : 'popup' } ` ,
774780 disableAnimations : this . _animationsDisabled ,
775781 } ) ,
@@ -825,14 +831,15 @@ export abstract class MatDatepickerBase<
825831
826832 /** Gets a position strategy that will open the calendar as a dropdown. */
827833 private _getDialogStrategy ( ) {
828- return this . _overlay . position ( ) . global ( ) . centerHorizontally ( ) . centerVertically ( ) ;
834+ return createGlobalPositionStrategy ( this . _injector ) . centerHorizontally ( ) . centerVertically ( ) ;
829835 }
830836
831837 /** Gets a position strategy that will open the calendar as a dropdown. */
832838 private _getDropdownStrategy ( ) {
833- const strategy = this . _overlay
834- . position ( )
835- . flexibleConnectedTo ( this . datepickerInput . getConnectedOverlayOrigin ( ) )
839+ const strategy = createFlexibleConnectedPositionStrategy (
840+ this . _injector ,
841+ this . datepickerInput . getConnectedOverlayOrigin ( ) ,
842+ )
836843 . withTransformOriginOn ( '.mat-datepicker-content' )
837844 . withFlexibleDimensions ( false )
838845 . withViewportMargin ( 8 )
0 commit comments