Skip to content

Commit 42e1961

Browse files
committed
fix(dialog,bottom-sheet): invert backdrop color on dark themes
Similarly to how we handle the sidenav backdrop and ripples, these changes invert the color for the dialog and bottom sheet backdrops in dark themes.
1 parent 4b82786 commit 42e1961

File tree

6 files changed

+16
-6
lines changed

6 files changed

+16
-6
lines changed

src/dev-app/dialog/dialog-demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class DialogDemo {
2828
disableClose: false,
2929
panelClass: 'custom-overlay-pane-class',
3030
hasBackdrop: true,
31-
backdropClass: '',
31+
backdropClass: defaultDialogConfig.backdropClass,
3232
width: '',
3333
height: '',
3434
minWidth: '',

src/material/bottom-sheet/_bottom-sheet-theme.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@
55
@mixin mat-bottom-sheet-theme($theme) {
66
$background: map-get($theme, background);
77
$foreground: map-get($theme, foreground);
8+
$backdrop-color: invert(mat-color($background, card, 0.288));
89

910
.mat-bottom-sheet-container {
1011
@include _mat-theme-elevation(16, $theme);
1112
background: mat-color($background, dialog);
1213
color: mat-color($foreground, text);
1314
}
15+
16+
.mat-bottom-sheet-backdrop {
17+
background: $backdrop-color;
18+
}
1419
}
1520

1621
@mixin mat-bottom-sheet-typography($config) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class MatBottomSheetConfig<D = any> {
3333
hasBackdrop?: boolean = true;
3434

3535
/** Custom class for the backdrop. */
36-
backdropClass?: string;
36+
backdropClass?: string = 'mat-bottom-sheet-backdrop';
3737

3838
/** Whether the user can use escape or clicking outside to close the bottom sheet. */
3939
disableClose?: boolean = false;

src/material/dialog/_dialog-theme.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,17 @@
77
@mixin mat-dialog-theme($theme) {
88
$background: map-get($theme, background);
99
$foreground: map-get($theme, foreground);
10+
$backdrop-color: invert(mat-color($background, card, 0.288));
1011

1112
.mat-dialog-container {
1213
@include _mat-theme-elevation(24, $theme);
1314
background: mat-color($background, dialog);
1415
color: mat-color($foreground, text);
1516
}
17+
18+
.mat-dialog-backdrop {
19+
background: $backdrop-color;
20+
}
1621
}
1722

1823
@mixin mat-dialog-typography($config) {

src/material/dialog/dialog-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class MatDialogConfig<D = any> {
5454
hasBackdrop?: boolean = true;
5555

5656
/** Custom class for the backdrop, */
57-
backdropClass?: string = '';
57+
backdropClass?: string = 'mat-dialog-backdrop';
5858

5959
/** Whether the user can use escape or clicking on the backdrop to close the modal. */
6060
disableClose?: boolean = false;

src/material/dialog/dialog.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export class MatDialog implements OnDestroy {
192192
* @returns The overlay configuration.
193193
*/
194194
private _getOverlayConfig(dialogConfig: MatDialogConfig): OverlayConfig {
195-
const state = new OverlayConfig({
195+
const overlayConfig = new OverlayConfig({
196196
positionStrategy: this._overlay.position().global(),
197197
scrollStrategy: dialogConfig.scrollStrategy || this._scrollStrategy(),
198198
panelClass: dialogConfig.panelClass,
@@ -206,10 +206,10 @@ export class MatDialog implements OnDestroy {
206206
});
207207

208208
if (dialogConfig.backdropClass) {
209-
state.backdropClass = dialogConfig.backdropClass;
209+
overlayConfig.backdropClass = dialogConfig.backdropClass;
210210
}
211211

212-
return state;
212+
return overlayConfig;
213213
}
214214

215215
/**

0 commit comments

Comments
 (0)