Skip to content

Commit 2dbfd72

Browse files
committed
refactor(material/bottom-sheet): switch to tree shakeable overlay APIs
Reworks the module to use the new tree-shakeable APIs for creating overlays.
1 parent 2d28807 commit 2dbfd72

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/material/bottom-sheet/bottom-sheet.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
*/
88

99
import {Dialog} from '@angular/cdk/dialog';
10-
import {Overlay} from '@angular/cdk/overlay';
10+
import {createBlockScrollStrategy, createGlobalPositionStrategy} from '@angular/cdk/overlay';
1111
import {ComponentType} from '@angular/cdk/portal';
12-
import {Injectable, TemplateRef, InjectionToken, OnDestroy, inject} from '@angular/core';
12+
import {Injectable, TemplateRef, InjectionToken, OnDestroy, inject, Injector} from '@angular/core';
1313
import {MAT_BOTTOM_SHEET_DATA, MatBottomSheetConfig} from './bottom-sheet-config';
1414
import {MatBottomSheetContainer} from './bottom-sheet-container';
1515
import {MatBottomSheetRef} from './bottom-sheet-ref';
@@ -25,7 +25,7 @@ export const MAT_BOTTOM_SHEET_DEFAULT_OPTIONS = new InjectionToken<MatBottomShee
2525
*/
2626
@Injectable({providedIn: 'root'})
2727
export class MatBottomSheet implements OnDestroy {
28-
private _overlay = inject(Overlay);
28+
private _injector = inject(Injector);
2929
private _parentBottomSheet = inject(MatBottomSheet, {optional: true, skipSelf: true});
3030
private _animationsDisabled = _animationsDisabled();
3131
private _defaultOptions = inject<MatBottomSheetConfig>(MAT_BOTTOM_SHEET_DEFAULT_OPTIONS, {
@@ -89,8 +89,10 @@ export class MatBottomSheet implements OnDestroy {
8989
closeOnOverlayDetachments: false,
9090
maxWidth: '100%',
9191
container: MatBottomSheetContainer,
92-
scrollStrategy: _config.scrollStrategy || this._overlay.scrollStrategies.block(),
93-
positionStrategy: this._overlay.position().global().centerHorizontally().bottom('0'),
92+
scrollStrategy: _config.scrollStrategy || createBlockScrollStrategy(this._injector),
93+
positionStrategy: createGlobalPositionStrategy(this._injector)
94+
.centerHorizontally()
95+
.bottom('0'),
9496
disableAnimations: this._animationsDisabled,
9597
templateContext: () => ({bottomSheetRef: ref}),
9698
providers: (cdkRef, _cdkConfig, container) => {

0 commit comments

Comments
 (0)