Bug[MatDialog]: disableClose=false not working with hasBackdrop=false
See original GitHub issueBug, feature request, or proposal:
- Bug
What is the expected behavior?
- The
disableClose
property, when set tofalse
, should allow the user to click outside of the modal to close it whenever thehasBackdrop
property is also set tofalse
.
What is the current behavior?
- If both the
disableClose
andhasBackdrop
properties are set tofalse
, the user should still be able to click outside of the modal to close it.
What are the steps to reproduce?
- Demo => https://angular-macdjt-y1ebqh.stackblitz.io
- Code for Demo => https://stackblitz.com/edit/angular-macdjt-y1ebqh
What is the use-case or motivation for changing an existing behavior?
- N/A
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
- Angular => 5
- Material => 5.2.2 & 5.2.3
- OS => Windows 10
- TypeScript => 2.4.x
- Browser(s) => Chrome (Version 64.0.3282.167 (Official Build) (64-bit))
Is there anything else we should know?
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Angular Material Dialog {hasBackdrop: false} - Stack Overflow
// We are setting disableClose to true, which means that the user will not be able to close the dialog just by clicking...
Read more >Angular Material Dialog: A Complete Example
In this post, we are going to go through a complete example of how to build a custom dialog using the Angular Material...
Read more >Dialog | Angular Material
Configuration for opening a modal dialog with the MatDialog service. ... This does not affect where the dialog content will be rendered. width:...
Read more >angular material dialog disable click outside - You.com
In the method that opens the dialog, pass in the following configuration option disableClose as the second parameter in MatDialog#open() and set it...
Read more >Ng Template Mat Dialog (forked) - StackBlitz
import { MatDialog } from '@angular/material'; ... constructor(private dialog: MatDialog) {}. @ViewChild('secondDialog', { static: ... hasBackdrop = false;.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The backdrop is used to handle the clicks outside the dialog. When you set
hasBackdrop
to false, the element won’t be rendered at all. If you don’t want the darkened backdrop, but still want clicking outside to work, you can set thebackdropClass
tocdk-overlay-transparent-backdrop
.I’d say that the config options are explicit enough. I don’t think that we can handle this automatically without making some assumptions which could break existing usages.