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.

Add support for hiding a dialog without closing it

See original GitHub issue

Bug, feature request, or proposal:

Only show one dialog at a time.

What is the expected behavior?

When a dialog is opened from within another dialog, all other open dialogs should be hidden.

What is the current behavior?

The new dialog gets layered on top of the old dialog(s)

What are the steps to reproduce?

  1. Open a dialog
  2. Open another dialog from within that dialog

Plunker: https://plnkr.co/edit/GglOLDnx1uJlZRgD4y1W?p=preview

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

In angularjs material, multiple dialogs weren’t allowed by default. See, for example http://plnkr.co/edit/qNu3q5XsIie1fYjKeJRc?p=preview. Ideally, though, there’d be a virtual stack of dialogs maintained, where only the topmost item on the stack is visible.

Is there anything else we should know?

Currently, I can work around the issue by running

Array.from(document.querySelectorAll(".cdk-overlay-container .cdk-global-overlay-wrapper")) .forEach((node, index, array) => (index !== array.length - 1) ? (<HTMLElement> node).style.display = "none" : true);

in ngOnInit, and running

Array.from(document.querySelectorAll(".cdk-overlay-container .cdk-global-overlay-wrapper")) .forEach((node) =>(<HTMLElement> node).style.display = "" );

in ngOnDestroy.

This works, and effectively creates a stack of hidden dialogs. But I don’t want to add that snippet in every dialog that could possibly be opened from another dialog.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
julianobrasilcommented, Aug 2, 2017

If the default behavior is to hide the dialog, maybe the hide API isn’t so confusing. An attribute in the parameter object passed to the open function would be simple to use. It would be something like

dialog.open({
  hideOnCascade: false 
});

The default behavior would be true. So the user could specify different when necessary.

1reaction
superMDguycommented, Aug 7, 2017

The PR @willshowell’s mentioned is a step in the right direction. Additionally, it’d be good to either have a way to add a class to a MdDialogRef, like @jelbourn suggested, or to have an automatically applied “inactive” class, like I suggested earlier. I like the “inactive” class better, because it makes things cleaner for me, but if it’s too much of a niche use case it might be better to just use @jelbourn’s suggestion.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Prevent closing of modal Dialog in Angular Dialog ...
You can prevent closing of modal dialog by setting the beforeClose event argument cancel value to true. In the following sample, the dialog...
Read more >
Disable click outside of angular material dialog area to close ...
There are two ways to do it. In the method that opens the dialog, pass in the following configuration option disableClose as the...
Read more >
Dialog | Angular Material
The MatDialogRef provides a handle on the opened dialog. It can be used to close the dialog and to receive notifications when the...
Read more >
Show/Hide Dialog Or Modal Service In Angular - C# Corner
In this article you will learn how to show/Hide Dialog or modal service in Angular.
Read more >
Angular Material Dialog: A Complete Example
panelClass : adds a list of custom CSS classes to the Dialog panel ... We can call it without any arguments if we...
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