Skip to content

Commit 54b671d

Browse files
committed
fixup! fix(material/dialog): css structure change
1 parent ef86b6b commit 54b671d

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/material/dialog/_mdc-dialog-structure-overrides.scss

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,5 @@
4242
width: 100%;
4343
height: 100%;
4444
}
45-
46-
// MDC sets the `surface` to `display: flex`. MDC does this in order to be able to make the
47-
// content scrollable while locking the title and actions. This only works in our dialog if we
48-
// set the children of the `surface` to `display: contents`. This is because, due to content
49-
// projection, arbitrary components can be immediate children of the surface and make this a
50-
// noop.
51-
.mat-mdc-dialog-surface > * {
52-
display: contents;
53-
}
5445
}
5546
}

src/material/dialog/dialog.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import {ComponentType, Overlay, OverlayContainer, ScrollStrategy} from '@angular/cdk/overlay';
10-
import {Location} from '@angular/common';
10+
import {DOCUMENT, Location} from '@angular/common';
1111
import {
1212
ANIMATION_MODULE_TYPE,
1313
ComponentRef,
@@ -20,6 +20,7 @@ import {
2020
SkipSelf,
2121
TemplateRef,
2222
Type,
23+
inject,
2324
} from '@angular/core';
2425
import {MatDialogConfig} from './dialog-config';
2526
import {_MatDialogContainerBase, MatDialogContainer} from './dialog-container';
@@ -76,6 +77,7 @@ export abstract class _MatDialogBase<C extends _MatDialogContainerBase> implemen
7677
protected _idPrefix = 'mat-dialog-';
7778
private _dialog: Dialog;
7879
protected dialogConfigClass = MatDialogConfig;
80+
private _document = inject(DOCUMENT, {optional: true});
7981

8082
/** Keeps track of the currently-open dialogs. */
8183
get openDialogs(): MatDialogRef<any>[] {
@@ -196,6 +198,14 @@ export abstract class _MatDialogBase<C extends _MatDialogContainerBase> implemen
196198
},
197199
});
198200

201+
if (!(componentOrTemplateRef instanceof TemplateRef)) {
202+
const children = this._document?.querySelectorAll('.mat-mdc-dialog-surface > *') || [];
203+
for (let i = 0; i < children.length; i++) {
204+
children[i].classList.add('mdc-dialog__surface');
205+
children[i].classList.add('mat-mdc-dialog-surface');
206+
}
207+
}
208+
199209
// This can't be assigned in the `providers` callback, because
200210
// the instance hasn't been assigned to the CDK ref yet.
201211
(dialogRef! as {componentRef: ComponentRef<T>}).componentRef = cdkRef.componentRef!;

0 commit comments

Comments
 (0)