Skip to content

Commit 462d407

Browse files
committed
fix(material-experimental/mdc-dialog): make align attr into an input of dialog actions directive
Fixes multiple issues, such as self-documentation of the align attribute, type checking, better bindings, and IDE support. Because align is not standard for HTMLDivElement, it doesn't make much sense to assume end users to know they can use the align attribute. Fixes angular#18479 for material-experimental
1 parent c101f7f commit 462d407

File tree

5 files changed

+1112
-1213
lines changed

5 files changed

+1112
-1213
lines changed

src/material-experimental/mdc-dialog/dialog-content-directives.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,13 @@ export class MatDialogContent {
139139
*/
140140
@Directive({
141141
selector: `[mat-dialog-actions], mat-dialog-actions, [matDialogActions]`,
142-
host: {'class': 'mat-mdc-dialog-actions mdc-dialog__actions'}
142+
host: {
143+
'class': 'mat-mdc-dialog-actions mdc-dialog__actions',
144+
'[class.mat-mdc-dialog-actions-align-center]': 'align === "center"',
145+
'[class.mat-mdc-dialog-actions-align-end]': 'align === "end"'}
143146
})
144147
export class MatDialogActions {
148+
@Input() align?: 'center' | 'end' = undefined;
145149
}
146150

147151

src/material-experimental/mdc-dialog/dialog.scss

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ $mat-dialog-button-horizontal-margin: 8px !default;
3434
// aligns actions at the end of the container.
3535
justify-content: start;
3636

37-
&[align='end'] {
38-
justify-content: flex-end;
39-
}
40-
41-
&[align='center'] {
37+
// .align-center and .align-end are set by directive input "align"
38+
&.mat-mdc-dialog-actions-align-center, &[align='center'] {
4239
justify-content: center;
4340
}
41+
&.mat-mdc-dialog-actions-align-end, &[align='end'] {
42+
justify-content: flex-end;
43+
}
4444

4545
// MDC applies horizontal margin to buttons that have an explicit `mdc-dialog__button`
4646
// class applied. We can't set this class for projected buttons that consumers of the

0 commit comments

Comments
 (0)