Skip to content

Commit 4a1f10e

Browse files
crisbetommalerba
authored andcommitted
fix(dialog): support passing in dialog result through all MdDialogClose selectors (#6293)
Fixes not being able to pass in a dialog result through the `mdDialogClose`, `matDialogClose` and `mat-dialog-close` selectors, even though they are allowed by the `MdDialogClose` directive. Fixes #6278.
1 parent 4ae1b0f commit 4a1f10e

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/lib/dialog/dialog-content-directives.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {Directive, Input, Optional, OnInit} from '@angular/core';
9+
import {Directive, Input, OnChanges, OnInit, Optional, SimpleChanges} from '@angular/core';
1010
import {MdDialogRef} from './dialog-ref';
1111
import {MdDialogContainer} from './dialog-container';
1212

@@ -25,17 +25,27 @@ let dialogElementUid = 0;
2525
'type': 'button', // Prevents accidental form submits.
2626
}
2727
})
28-
export class MdDialogClose {
28+
export class MdDialogClose implements OnChanges {
2929
/** Screenreader label for the button. */
3030
@Input('aria-label') ariaLabel: string = 'Close dialog';
3131

3232
/** Dialog close input. */
3333
@Input('md-dialog-close') dialogResult: any;
3434

35-
/** Dialog close input for compatibility mode. */
36-
@Input('mat-dialog-close') set _matDialogClose(value: any) { this.dialogResult = value; }
35+
@Input('matDialogClose') _matDialogClose: any;
36+
@Input('mdDialogClose') _mdDialogClose: any;
37+
@Input('mat-dialog-close') _matDialogCloseResult: any;
3738

3839
constructor(public dialogRef: MdDialogRef<any>) { }
40+
41+
ngOnChanges(changes: SimpleChanges) {
42+
const proxiedChange = changes._matDialogClose || changes._mdDialogClose ||
43+
changes._matDialogCloseResult;
44+
45+
if (proxiedChange) {
46+
this.dialogResult = proxiedChange.currentValue;
47+
}
48+
}
3949
}
4050

4151
/**

0 commit comments

Comments
 (0)