@@ -162,6 +162,18 @@ export abstract class _MatDialogBase<C extends _MatDialogContainerBase> implemen
162
162
config . id = config . id || `${ this . _idPrefix } ${ uniqueId ++ } ` ;
163
163
config . scrollStrategy = config . scrollStrategy || this . _scrollStrategy ( ) ;
164
164
165
+ // When a component is passed into the dialog, the host element interrupts
166
+ // the `display:flex` from affecting the dialog title, content, and
167
+ // actions. To fix this, we make the component host `display: contents` by
168
+ // marking it's panel with the `mat-mdc-dialog-component-panel` class.
169
+ //
170
+ // Note that this problem does not exist when a template ref is used since
171
+ // the title, contents, and actions are then nested directly under the
172
+ // dialog surface.
173
+ if ( ! ( componentOrTemplateRef instanceof TemplateRef ) ) {
174
+ this . _appendPanelClass ( config , 'mat-mdc-dialog-component-panel' ) ;
175
+ }
176
+
165
177
const cdkRef = this . _dialog . open < R , D , T > ( componentOrTemplateRef , {
166
178
...config ,
167
179
positionStrategy : this . _overlay . position ( ) . global ( ) . centerHorizontally ( ) . centerVertically ( ) ,
@@ -249,6 +261,17 @@ export abstract class _MatDialogBase<C extends _MatDialogContainerBase> implemen
249
261
dialogs [ i ] . close ( ) ;
250
262
}
251
263
}
264
+
265
+ /** Appends the given class name to the panel via the dialog config. */
266
+ private _appendPanelClass ( config : MatDialogConfig , className : string ) {
267
+ if ( Array . isArray ( config . panelClass ) ) {
268
+ config . panelClass . push ( className ) ;
269
+ } else if ( typeof config . panelClass === 'string' ) {
270
+ config . panelClass = [ config . panelClass , className ] ;
271
+ } else {
272
+ config . panelClass = className ;
273
+ }
274
+ }
252
275
}
253
276
254
277
/**
0 commit comments