Skip to content

Add support for hiding a dialog without closing it #6206

Closed
@superMDguy

Description

@superMDguy

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentfeatureThis issue represents a new feature or feature request rather than a bug or bug fixhelp wantedThe team would appreciate a PR from the community to address this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions