question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MatDialog - hasBackdrop/disableClose conflict with each other

See original GitHub issue

Bug, feature request, or proposal:

Bug

What is the expected behavior?

MatDialogConfig disableClose should function like the documentation states:

disableClose: boolean | Whether the user can use escape or clicking outside to close a modal.

What is the current behavior?

When configuration the MatDialogConfig to include hasBackdrop: false, you lose the ability to close the modal when a user clicks outside of it. This is to also say that mentioning disableClose in the config does nothing if hasBackdrop is false

What are the steps to reproduce?

Providing a StackBlitz reproduction is the best way to share your issue.
StackBlitz starter: https://goo.gl/wwnhMV

https://stackblitz.com/edit/angular-ev6jqa?file=app/dialog-overview-example.ts

What is the use-case or motivation for changing an existing behavior?

Quality

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Angular 5 and 6

Is there anything else we should know?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
marc-wilsoncommented, Jun 7, 2018

The workaround is to not use disableBackgrop or disableClose but use backdropClass instead:

.g-transparent-backdrop {
  background: rgba(255, 255, 255, 0.288);
  opacity: 0.2;
}
const dialogRef = this._matDialog.open(MyDialogComponent, {
      backdropClass: 'g-transparent-backdrop',
      data: {
        foo: bar
      }
    });
0reactions
angular-automatic-lock-bot[bot]commented, Sep 9, 2019

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular 2: prevent user to click outside the modal dialog
I think you need to do something like this: this.dialogRef = this.dialog.open(DialogResultComponent, { disableClose ...
Read more >
How To Prevent MatDialog From Closing When Clicked Outside
In this blog, you will learn how to prevent MatDialog from closing ... a built-in property called disableClose the prevents this behavior.
Read more >
@angular/material | Yarn - Package Manager
The Angular team builds and maintains both common UI components and tools to help you build your own custom components. The team maintains...
Read more >
UNPKG - @angular/material
n *\n * This module should be imported to each top-level component module (e.g., MatTabsModule) ... n * Null dates are considered equal...
Read more >
demo/node_modules/@angular/material/@angular ... - GitLab
n * Captures the header row's template and other header properties such as the columns ... Property with mat- prefix for no-conflict mode....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found