Skip to content

feat(MatDialog): Accept a function on MatDialogRef's disableClose #25867

Open
@robmv

Description

@robmv

Feature Description

Currently MatDialogRef's disableClose type is boolean | undefined. Allow another function type like () => boolean in order to have dynamic checks before processing the ESC key or clicking outside the dialog.

Use Case

The most use I have of disableClose is to disable it when a form is dirty. As there is no event yet on Angular for the dirty state, I have to resort to:

 ngDoCheck(): void {
    // WORKAROUND Remove when there are proper events for dirty status changes
    this.dialogRef.disableClose = this.form.dirty;
  }

It would help a lot if disableClose could be function that can check, in my case, the form dirty state and that way remove the DoCheck lifecycle event.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/dialogfeatureThis issue represents a new feature or feature request rather than a bug or bug fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions