Skip to content

Commit bf1bdc0

Browse files
crisbetojosephperrott
authored andcommitted
fix(dialog): add generic parameter for the dialog result to open method (#11059)
1 parent cfe6c1d commit bf1bdc0

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/lib/dialog/dialog.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ export class MatDialog {
114114
* @param config Extra configuration options.
115115
* @returns Reference to the newly-opened dialog.
116116
*/
117-
open<T, D = any>(componentOrTemplateRef: ComponentType<T> | TemplateRef<T>,
118-
config?: MatDialogConfig<D>): MatDialogRef<T> {
117+
open<T, D = any, R = any>(componentOrTemplateRef: ComponentType<T> | TemplateRef<T>,
118+
config?: MatDialogConfig<D>): MatDialogRef<T, R> {
119119

120120
config = _applyConfigDefaults(config, this._defaultOptions || new MatDialogConfig());
121121

@@ -125,8 +125,10 @@ export class MatDialog {
125125

126126
const overlayRef = this._createOverlay(config);
127127
const dialogContainer = this._attachDialogContainer(overlayRef, config);
128-
const dialogRef =
129-
this._attachDialogContent<T>(componentOrTemplateRef, dialogContainer, overlayRef, config);
128+
const dialogRef = this._attachDialogContent<T, R>(componentOrTemplateRef,
129+
dialogContainer,
130+
overlayRef,
131+
config);
130132

131133
// If this is the first dialog that we're opening, hide all the non-overlay content.
132134
if (!this.openDialogs.length) {
@@ -221,15 +223,16 @@ export class MatDialog {
221223
* @param config The dialog configuration.
222224
* @returns A promise resolving to the MatDialogRef that should be returned to the user.
223225
*/
224-
private _attachDialogContent<T>(
226+
private _attachDialogContent<T, R>(
225227
componentOrTemplateRef: ComponentType<T> | TemplateRef<T>,
226228
dialogContainer: MatDialogContainer,
227229
overlayRef: OverlayRef,
228-
config: MatDialogConfig): MatDialogRef<T> {
230+
config: MatDialogConfig): MatDialogRef<T, R> {
229231

230232
// Create a reference to the dialog we're creating in order to give the user a handle
231233
// to modify and close it.
232-
const dialogRef = new MatDialogRef<T>(overlayRef, dialogContainer, this._location, config.id);
234+
const dialogRef =
235+
new MatDialogRef<T, R>(overlayRef, dialogContainer, this._location, config.id);
233236

234237
// When the dialog backdrop is clicked, we want to close it.
235238
if (config.hasBackdrop) {

0 commit comments

Comments
 (0)