@@ -27,6 +27,9 @@ export class MatBottomSheetRef<T = any, R = any> {
27
27
*/
28
28
containerInstance : MatBottomSheetContainer ;
29
29
30
+ /** Whether the user is allowed to close the bottom sheet. */
31
+ disableClose : boolean | undefined ;
32
+
30
33
/** Subject for notifying the user that the bottom sheet has been dismissed. */
31
34
private readonly _afterDismissed = new Subject < R | undefined > ( ) ;
32
35
@@ -42,6 +45,7 @@ export class MatBottomSheetRef<T = any, R = any> {
42
45
// @breaking -change 8.0.0 `_location` parameter to be removed.
43
46
_location ?: Location ) {
44
47
this . containerInstance = containerInstance ;
48
+ this . disableClose = containerInstance . bottomSheetConfig . disableClose ;
45
49
46
50
// Emit when opening animation completes
47
51
containerInstance . _animationStateChanged . pipe (
@@ -64,12 +68,14 @@ export class MatBottomSheetRef<T = any, R = any> {
64
68
this . _afterDismissed . complete ( ) ;
65
69
} ) ;
66
70
67
- if ( ! containerInstance . bottomSheetConfig . disableClose ) {
68
- merge (
69
- _overlayRef . backdropClick ( ) ,
70
- _overlayRef . keydownEvents ( ) . pipe ( filter ( event => event . keyCode === ESCAPE ) )
71
- ) . subscribe ( ( ) => this . dismiss ( ) ) ;
72
- }
71
+ merge (
72
+ _overlayRef . backdropClick ( ) ,
73
+ _overlayRef . keydownEvents ( ) . pipe ( filter ( event => event . keyCode === ESCAPE ) )
74
+ ) . subscribe ( ( ) => {
75
+ if ( ! this . disableClose ) {
76
+ this . dismiss ( ) ;
77
+ }
78
+ } ) ;
73
79
}
74
80
75
81
/**
0 commit comments