-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Closed
Description
Bug, feature request, or proposal:
Bug
What is the expected behavior?
Should be able to close dialog
What is the current behavior?
Cannot close dialog - for a predictable/certain code path
What are the steps to reproduce?
Here is the problem:
https://www.useloom.com/share/7eb9c523ee3144fb94bb2b49b57dee1b
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular5, Material2, MacOS, tsc version 2.6.1
More info
in both cases, the dialog is created using the same code, here is the code to create dialog:
'use strict';
import {Component, OnInit, Inject, Injectable} from '@angular/core';
import {MainDataService} from '../../services/main';
import {MAT_DIALOG_DATA, MatDialogRef, MatDialogConfig} from '@angular/material';
import {MatDialog} from '@angular/material/dialog';
@Component({
templateUrl: './stop-recording-dialog.component.html',
styleUrls: ['./stop-recording-dialog.component.scss']
})
export class StopRecordingDialogComponent implements OnInit {
public dialogResult: any;
escapeToClose = true;
constructor(public dialogRef: MatDialogRef<StopRecordingDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: string,
private mds: MainDataService) {
}
onClickClose() {
this.dialogRef.close();
this.mds.dialogEmitter.emit({
name: 'stop-recording-run-dialog-closed',
value: 'x'
});
}
}
@Injectable()
export class StopRecordingDialog {
escapeToClose = true;
dialogRef: MatDialogRef<StopRecordingDialogComponent> | null;
config = Object.assign(new MatDialogConfig(), {
width: '600px',
data: 'This text is passed into the dialog!'
});
constructor(public dialog: MatDialog, private mds: MainDataService) {}
openDialog() {
this.dialogRef = this.dialog.open(StopRecordingDialogComponent, this.config);
this.dialogRef.beforeClose().subscribe((result: string) => {
console.log(`Dialog before closed: ${result}`);
});
this.dialogRef.afterClosed().subscribe(result => {
console.log(`Dialog after closed: ${result}`);
});
}
}
even when it fails to close, the onClickClose()
method is called, so not sure why the dialog won't close.
Metadata
Metadata
Assignees
Labels
No labels