material icon indicating copy to clipboard operation
material copied to clipboard

Multiple dialogs

Open palavrov opened this issue 10 years ago • 14 comments

Starting a new issue because #698 is locked.

Seems that passing skipHide:true to mdDialog options allow multiple dialogs. There are just two small issues that probably can be easily fixed:

  • second backdrop doesn't cover the first dialog instead it goes behind it. Probably playing with Z order can help.
  • Sometimes closing the dialogs goes in reverse order i.e. first closes the dialog underneath.

palavrov avatar Feb 24 '16 09:02 palavrov

+1 skipHIde works very well... BUT if the controller has for instance:

this.$mdDialog.cancel();

This closes the parent first. Then if cancel() is engaged again then it closes the child. So as palavrov said they are closing in reverse order... or reacting in reverse order...

SMALL UPDATE:

if you use this.$mdDialog.hide() it works!!!!

scriptsure avatar Feb 24 '16 16:02 scriptsure

@scriptsure, actually it is more weird than that. If I'm not wrong when you create the dialog with $mdDialog.alert({..}) for example (and overriding all predefined properties to create actually a custom one) then the order is right. Don't see obvious reason for that behavior in the source but honestly didn't spend too much time to investigate because right now it is good enough for my project.

palavrov avatar Feb 24 '16 19:02 palavrov

Not supported until v2.x

ThomasBurleson avatar Feb 24 '16 23:02 ThomasBurleson

Hi, i put this in my css to solve the second backdrop:

._md-dialog-backdrop:nth-of-type(even) {
    z-index: 81;
}

._md-dialog-backdrop:nth-of-type(odd) {
    z-index: 79;
}

.md-dialog-container:nth-of-type(even) {
    z-index: 80;
}

.md-dialog-container:nth-of-type(odd) {
    z-index: 82;
}

It works for me for 2 dialogs using skipHide:true. Is it good? or wrong?

enzonotario avatar May 14 '16 16:05 enzonotario

@enzonotario For second backdrop, I tried your CSS and it doesn't seem to work. Anything else you did?

char-chen avatar Sep 13 '16 00:09 char-chen

Hi @chenchfort . I use skipHide: true in the options object. The css is only for add a "second backdrop" for the second dialog, so the first dialog will be below the "second backdrop". Now, can you open two dialogs?

I'm sorry but I don't speak english so well, but if I can, I'm willing to help you.

enzonotario avatar Sep 13 '16 19:09 enzonotario

Sorry! reading again your comment I think that you already can open two dialogs! LOL (my english is SO poor). Now... the previous code work for me in any previous version (I don't remember what version). Now it doesn't work.

With anuglar material v1.0.9 this code works:

.md-dialog-backdrop:nth-of-type(even) {
    z-index: 81;
}

.md-dialog-backdrop:nth-of-type(odd) {
    z-index: 79;
}

.md-dialog-container:nth-of-type(even) {
    z-index: 80;
}

.md-dialog-container:nth-of-type(odd) {
    z-index: 82;
}

I only remove the first _.

Regards!

enzonotario avatar Sep 13 '16 19:09 enzonotario

@enzonotario Thanks. It still doesn't work particularly in my case. I notice that the second backdrop shows up when I open up a container like md-select though.

char-chen avatar Sep 17 '16 06:09 char-chen

Sorry! Try with this code:

.md-dialog-backdrop:nth-of-type(even) {
    z-index: 81;
}

.md-dialog-backdrop:nth-of-type(odd) {
    z-index: 79;
}

.md-dialog-container:nth-of-type(even) {
    z-index: 82;
}

.md-dialog-container:nth-of-type(odd) {
    z-index: 80;
}

sin nombre

enzonotario avatar Sep 20 '16 12:09 enzonotario

@enzonotario Still doesn't show the second backdrop on my regular parent dialog (md-select issue is resolved though). Can you provide a plunker? Thank you so much for the help!

char-chen avatar Sep 20 '16 20:09 char-chen

Hi! http://codepen.io/enzonotario/pen/vXmPzR

enzonotario avatar Sep 27 '16 12:09 enzonotario

More reliable version of the above code. Obviously only works for a second popup, no further than that.

.md-dialog-backdrop {
  z-index: 79;
}

.md-dialog-backdrop ~ .md-dialog-backdrop {
  z-index: 81;
}

.md-dialog-container {
  z-index: 80;
}

.md-dialog-container ~ .md-dialog-container {
  z-index: 82;
}

efraimbart avatar Jan 11 '17 20:01 efraimbart

A note to anyone that are about to try above solutions - changing the z-index of md-dialog-container prevents your md-select from closing by clicking elsewhere on the page (including the dialog it originates from). You can even see this on codepen enzonotario provided.

I think I have managed to fix this issue though:

.md-dialog-backdrop {
  z-index: 78;
}

.md-dialog-backdrop ~ .md-dialog-backdrop {
  z-index: 79;
}

md-backdrop.md-dialog-backdrop {
    z-index: 78;
}

.md-dialog-container {
  z-index: 78;
}

.md-dialog-container ~ .md-dialog-container {
  z-index: 80;
}

relair avatar Jul 25 '17 10:07 relair

For confirm and alert dialog, it'll be better to use .parent with skipHide/multiple:

        var confirmDialog = $mdDialog.confirm({skipHide/multiple: true})
            .title('Please confirm')
            .textContent('Are you sure you want to delete this message?')
            .parent(angular.element(document.querySelector('#parentDialogId')))
            .ok('Yes')
            .cancel('No')
            .multiple(true);

        $mdDialog.show(confirmDialog).then(function(){}

skipHide for older versions & multiple for newer...

abheist avatar Sep 06 '17 11:09 abheist