@@ -430,6 +430,7 @@ export class MatDrawer implements AfterContentInit, AfterContentChecked, OnDestr
430
430
styleUrls : [ 'drawer.css' ] ,
431
431
host : {
432
432
'class' : 'mat-drawer-container' ,
433
+ '[class.mat-drawer-container-explicit-backdrop]' : '_backdropOverride' ,
433
434
} ,
434
435
changeDetection : ChangeDetectionStrategy . OnPush ,
435
436
encapsulation : ViewEncapsulation . None ,
@@ -458,19 +459,23 @@ export class MatDrawerContainer implements AfterContentInit, OnDestroy {
458
459
set autosize ( value : boolean ) { this . _autosize = coerceBooleanProperty ( value ) ; }
459
460
private _autosize : boolean ;
460
461
461
- /** Whether the drawer container should have a backdrop while one of the sidenavs is open. */
462
+ /**
463
+ * Whether the drawer container should have a backdrop while one of the sidenavs is open.
464
+ * If explicitly set to `true`, the backdrop will be enabled for drawers in the `side`
465
+ * mode as well.
466
+ */
462
467
@Input ( )
463
468
get hasBackdrop ( ) {
464
- if ( this . _hasBackdrop == null ) {
469
+ if ( this . _backdropOverride == null ) {
465
470
return ! this . _start || this . _start . mode !== 'side' || ! this . _end || this . _end . mode !== 'side' ;
466
471
}
467
472
468
- return this . _hasBackdrop ;
473
+ return this . _backdropOverride ;
469
474
}
470
475
set hasBackdrop ( value : any ) {
471
- this . _hasBackdrop = value == null ? null : coerceBooleanProperty ( value ) ;
476
+ this . _backdropOverride = value == null ? null : coerceBooleanProperty ( value ) ;
472
477
}
473
- private _hasBackdrop : boolean | null ;
478
+ _backdropOverride : boolean | null ;
474
479
475
480
/** Event emitted when the drawer backdrop is clicked. */
476
481
@Output ( ) readonly backdropClick : EventEmitter < void > = new EventEmitter < void > ( ) ;
@@ -663,8 +668,8 @@ export class MatDrawerContainer implements AfterContentInit, OnDestroy {
663
668
664
669
/** Whether the container is being pushed to the side by one of the drawers. */
665
670
private _isPushed ( ) {
666
- return ( this . _isDrawerOpen ( this . _start ) && this . _start ! . mode != 'over' ) ||
667
- ( this . _isDrawerOpen ( this . _end ) && this . _end ! . mode != 'over' ) ;
671
+ return ( this . _isDrawerOpen ( this . _start ) && this . _start . mode != 'over' ) ||
672
+ ( this . _isDrawerOpen ( this . _end ) && this . _end . mode != 'over' ) ;
668
673
}
669
674
670
675
_onBackdropClicked ( ) {
@@ -675,16 +680,20 @@ export class MatDrawerContainer implements AfterContentInit, OnDestroy {
675
680
_closeModalDrawer ( ) {
676
681
// Close all open drawers where closing is not disabled and the mode is not `side`.
677
682
[ this . _start , this . _end ]
678
- . filter ( drawer => drawer && ! drawer . disableClose && drawer . mode !== 'side' )
683
+ . filter ( drawer => drawer && ! drawer . disableClose && this . _canHaveBackdrop ( drawer ) )
679
684
. forEach ( drawer => drawer ! . close ( ) ) ;
680
685
}
681
686
682
687
_isShowingBackdrop ( ) : boolean {
683
- return ( this . _isDrawerOpen ( this . _start ) && this . _start ! . mode != 'side' )
684
- || ( this . _isDrawerOpen ( this . _end ) && this . _end ! . mode != 'side' ) ;
688
+ return ( this . _isDrawerOpen ( this . _start ) && this . _canHaveBackdrop ( this . _start ) ) ||
689
+ ( this . _isDrawerOpen ( this . _end ) && this . _canHaveBackdrop ( this . _end ) ) ;
690
+ }
691
+
692
+ private _canHaveBackdrop ( drawer : MatDrawer ) : boolean {
693
+ return drawer . mode !== 'side' || ! ! this . _backdropOverride ;
685
694
}
686
695
687
- private _isDrawerOpen ( drawer : MatDrawer | null ) : boolean {
696
+ private _isDrawerOpen ( drawer : MatDrawer | null ) : drawer is MatDrawer {
688
697
return drawer != null && drawer . opened ;
689
698
}
690
699
0 commit comments