Skip to content

Commit fe96f38

Browse files
crisbetovivian-hu-zz
authored andcommitted
fix(dialog,bottom-sheet): invert backdrop color on dark themes (#13065)
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 5dfa45f commit fe96f38

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/lib/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/lib/bottom-sheet/bottom-sheet-config.ts

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

3434
/** Custom class for the backdrop. */
35-
backdropClass?: string;
35+
backdropClass?: string = 'mat-bottom-sheet-backdrop';
3636

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

src/lib/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/lib/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/lib/dialog/dialog.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ export class MatDialog implements OnDestroy {
189189
* @returns The overlay configuration.
190190
*/
191191
private _getOverlayConfig(dialogConfig: MatDialogConfig): OverlayConfig {
192-
const state = new OverlayConfig({
192+
const overlayConfig = new OverlayConfig({
193193
positionStrategy: this._overlay.position().global(),
194194
scrollStrategy: dialogConfig.scrollStrategy || this._scrollStrategy(),
195195
panelClass: dialogConfig.panelClass,
@@ -203,10 +203,10 @@ export class MatDialog implements OnDestroy {
203203
});
204204

205205
if (dialogConfig.backdropClass) {
206-
state.backdropClass = dialogConfig.backdropClass;
206+
overlayConfig.backdropClass = dialogConfig.backdropClass;
207207
}
208208

209-
return state;
209+
return overlayConfig;
210210
}
211211

212212
/**

0 commit comments

Comments
 (0)