@@ -27,6 +27,9 @@ export class MatBottomSheetRef<T = any, R = any> {
2727 */
2828 containerInstance : MatBottomSheetContainer ;
2929
30+ /** Whether the user is allowed to close the bottom sheet. */
31+ disableClose : boolean | undefined ;
32+
3033 /** Subject for notifying the user that the bottom sheet has been dismissed. */
3134 private readonly _afterDismissed = new Subject < R | undefined > ( ) ;
3235
@@ -42,6 +45,7 @@ export class MatBottomSheetRef<T = any, R = any> {
4245 // @breaking -change 8.0.0 `_location` parameter to be removed.
4346 _location ?: Location ) {
4447 this . containerInstance = containerInstance ;
48+ this . disableClose = containerInstance . bottomSheetConfig . disableClose ;
4549
4650 // Emit when opening animation completes
4751 containerInstance . _animationStateChanged . pipe (
@@ -64,12 +68,14 @@ export class MatBottomSheetRef<T = any, R = any> {
6468 this . _afterDismissed . complete ( ) ;
6569 } ) ;
6670
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+ } ) ;
7379 }
7480
7581 /**
0 commit comments