Skip to content

Hiding a MdDialog #5162

Closed
Closed

Description

@MaximeAnsquer

Bug, feature request, or proposal:

Feature request

What is the expected behavior?

Ability to hide the MdDialog and then show it back, with the component inside of it not being changed.

What is the current behavior?

The component can only be closed, and the component inside is destroyed.

What are the steps to reproduce?

Open a dialog, change something inside it, close it, open it back, and see that the change is gone.

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

For example with a form inside a MdDialog, resetting the form when the dialog is closed/hidden is very annoying.

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

Angular 4.2.0-rc.2, Material 2.0.0-beta.6, any OS, any TypeScript version, any Browser

Activity

  1. julianobrasil commented on Jun 16, 2017

    @julianobrasil
    Contributor

    Have you tried binding it to some property of the component that is calling it?

    You can use an object (not a primitive type) and pass it to the dialog to initialize it (dialogRef.componentInstance.instanceObj = this.callingComponentObj), then if, inside the dialog, you bind the controls (with [(ngModel)], for example) to the attributes of the dialog's instanceObj, any change you do to them will be reflected in calling component's callingComponentObj and can be used in future calls to the dialog. If this dialog is called accross the app, you can think of a service to host callingComponentObj.

  2. MaximeAnsquer commented on Jun 16, 2017

    @MaximeAnsquer
    Author

    Nice idea, I will try that.

    Thanks !

  3. added
    feature
    P4
    on Jun 20, 2017
  4. moravcik commented on Aug 7, 2017

    @moravcik

    Binding inputs is not a problem. In my case the UI inside of dialog is, let's say "expensive", e.g. multiple interactive maps. Building the dialog content UI every time is not very effective, I would need just to hide or show it.

  5. karol-depka commented on Sep 12, 2017

    @karol-depka

    Please increase the priority. I don't think this is minor. My dialog has expensive components inside (Google Maps) and every time the dialog is opened, the app progressively slows down, down to a crawl...

  6. willshowell commented on Sep 13, 2017

    @willshowell
    Contributor

    @karol-depka, there is a "P3" duplicate at #6206. The official consensus seems to be:

    Instead, I think it would make sense to add the ability to add/remove css classes to the dialog via MdDialogRef

    It's open for community contribution if anyone cares to give it a shot!

  7. smkart commented on Aug 15, 2018

    @smkart

    Much need feature , I have child components inside the dialog window , for with previous instance and values are needed , I would be better just to hide and open the dialog instead of passing the reference each time it opens dialog

  8. xmlking commented on Jan 30, 2019

    @xmlking

    Chat-Bot Dialog/Popup is potential examples for this use case.

  9. julianobrasil commented on Jan 30, 2019

    @julianobrasil
    Contributor

    @willshowell submited an already merged PR about this topic: #14772.

  10. jelbourn commented on Nov 7, 2019

    @jelbourn
    Contributor

    Closing since MatDialogRef supports this now (via CSS classes)

  11. angular-automatic-lock-bot commented on Dec 8, 2019

    @angular-automatic-lock-bot

    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.

  12. locked and limited conversation to collaborators on Dec 8, 2019
  13. added
    needs: discussion
    on Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4featureneeds: discussion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions