Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Enhancement to open multiple dialogs using $mdDialog #8630

Closed
denver-HJS opened this issue Jun 2, 2016 · 28 comments
Closed

Enhancement to open multiple dialogs using $mdDialog #8630

denver-HJS opened this issue Jun 2, 2016 · 28 comments
Assignees
Labels
- Lots of Comments has: Pull Request A PR has been created to address this issue P3: important Important issues that really should be fixed when possible. resolution: fixed type: enhancement
Milestone

Comments

@denver-HJS
Copy link

Hello,

I am inquiring to find out whether or not there are plans to add functionality to the $mdDialog service for showing multiple dialogs. I am aware of this thread but I'd like to rekindle the discussion.

My specific need is that my application requires a virtual keyboard. I implemented this virtual keyboard using a wrapper service around $mdDialog (and a separate directive). This worked flawlessly...up until the point I tried to apply my virtual keyboard to an input that's inside of a dialog. Once the user clicks the input within the dialog it goes away and up comes the keyboard.

1) Is there any chance that having multiple dialogs will be implemented in the future?
2) Does anyone have suggestions for working around this limitation?

I found the options $mdDialog provides to be extremely useful, so it's disappointing to rearrange my architecture and try to recreate the niceties myself.

showKeyboard(keyboardType, inputElement, modelUpdateEvent, customValidation) {
      var s = this;
      let positionKeyboard = () => {
        $('#keyboard-dialog').position({
          of: $(inputElement),
          my: "right top",
          at: "right bottom",
          collision: "flipfit flipfit"
        });
        s._isDragging = false;
        let dragDelay = 1000;
        let dragTimeout = undefined;
        $('#keyboard-dialog').on("mousedown", () => {
          if(s._isDragging == false) {
            dragTimeout = this._$timeout(() => {
              s._isDragging = true;
              s._dragStartTime = moment();
              let draggingMask = $.parseHTML(`<div class="drag-mask"></div>`);
              $(draggingMask).css({
                position: 'absolute',
                width: '100%',
                height: '100%',
                top: '0px',
                left: '0px',
                zIndex: 100
              });
              $('#keyboard-dialog').append(draggingMask);
              $('#keyboard-dialog').css({
                border: '3px solid rgb(86, 180, 239)',
                'box-shadow': '0px 1px 3px rgba(0, 0, 0, 0.05) inset, 0px 0px 8px rgba(82, 168, 236, 0.6)'
              });
              $('#keyboard-dialog').draggable();
            }, dragDelay);
          }
        });

        $('#keyboard-dialog').on("mouseup", () => {
          if(angular.isDefined(dragTimeout)) {
            s._$timeout.cancel(dragTimeout);
            dragTimeout = undefined;
          }
          let now = moment();
          let timespan = moment.duration(now.diff(s._dragStartTime));
          if($(".drag-mask").length && s._isDragging && timespan.asMilliseconds() > 700) {
            s._isDragging = false;
            $(".drag-mask").remove();
            $('#keyboard-dialog').css({
              border: 'none',
              'box-shadow': 'none'
            });
            $('#keyboard-dialog').draggable("destroy");
          }
        });
      };

      this._$mdDialog.show({
        templateUrl: 'partials/dialogs/keyboard/keyboardDialog.html',
        controller: 'keyboardDialogController as vm',
        clickOutsideToClose: true,
        hasBackdrop: false,
        //openFrom: inputElement,
        closeTo: inputElement,
        onComplete: positionKeyboard,
        locals: {
          keyboardType: keyboardType,
          inputElement: inputElement,
          modelUpdateEvent: modelUpdateEvent,
          customValidation: customValidation
        }
      })
      .then(
        () => { $(inputElement).trigger("blur"); },
        () => { $(inputElement).trigger("blur"); }
      );
    }
@devversion
Copy link
Member

devversion commented Jun 3, 2016

We do not have plans to support it the new future. But we will create the base for multiple interim elements (like the dialog) in #8624. So once #8624 is ready, we'll probably revisit the multiple dialogs issue.

@devversion devversion self-assigned this Jun 3, 2016
@devversion devversion added the P2: required Issues that must be fixed. label Jun 3, 2016
@denver-HJS
Copy link
Author

Alright, understood. Thanks for the quick feedback =)

@jaymanned
Copy link

@devversion Will you let us know here if you finally manage to revisit the multiple dialogs issue?

@devversion
Copy link
Member

@jaymanned Definitely yes! It's just a lower priority on my queue for now, but will definitely revisit that issue.

devversion added a commit to devversion/material that referenced this issue Jul 16, 2016
* Adds support for multiple interim elements (like dialog)
* When single interim (default) is enabled, then interims should hide properly (as in toasts).

Fixes angular#8624. References angular#8630.
@devversion devversion added the in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs label Jul 17, 2016
@olingern
Copy link

olingern commented Jul 18, 2016

Copying and pasting my comment from #3072 for others who may stumble upon this or are unaware of existing functionality:


Unsure why this isn't documented, but using skipHide on the child dialog will allow this.

Here's a plunker

And here's the line of code that "skips" hiding the parent dialog.

@devversion
Copy link
Member

@olingern This is not documented, because it's currently only internal and designed for use with the $mdMenu.

In #9053, skipHide` has been redesigned to properly handle multiple interims at the same time.

@olingern
Copy link

@devversion I see... and awesome. Thanks for your work on this!

So as of #9053 you migrate skipHide to multiple and keep a stack of shown interim elements?

@devversion
Copy link
Member

@olingern - Exactly skipHide will be renamed to multiple.

  • Once multiple is disabled (by default), the previous interim, when a new interim will be shown, will hide properly. (This was not the case before - overlapping toasts e.g)
  • Keeping track of interims, which are currently opening | open | closing.
    This allows us to properly support cancellation / hiding of multiple interims.

@olingern
Copy link

Thanks for this. Super helpful for confirmations when inside a modal. I'm sure #698, #3072 will welcome the changes, too. Cheers.

devversion added a commit to devversion/material that referenced this issue Sep 1, 2016
* Adds support for multiple interim elements (like dialog)
* When single interim (default) is enabled, then interims should hide properly (as in toasts).

Fixes angular#8624. References angular#8630.
jelbourn pushed a commit that referenced this issue Sep 21, 2016
* feat(interimElement): properly handle multiple interims.

* Adds support for multiple interim elements (like dialog)
* When single interim (default) is enabled, then interims should hide properly (as in toasts).

Fixes #8624. References #8630.

* When hiding wait for currenlty opening interims

* Address EladBezalel's feedback

* Wait for interim element for cancel as well

* Address EladBezalel's feedback
milespetrov pushed a commit to milespetrov/fgpv-vpgf that referenced this issue Sep 22, 2016
Currently $mdDialog does not support multiple dialogs at one time. Updated
focus manager to only close dialogs in WAITING state.

See [this angular material
issue](angular/material#8630)

Closes fgpv-vpgf#1215
milespetrov pushed a commit to milespetrov/fgpv-vpgf that referenced this issue Sep 23, 2016
Currently $mdDialog does not support multiple dialogs at one time. Updated
focus manager to only close dialogs in WAITING state.

See [this angular material
issue](angular/material#8630)

Closes fgpv-vpgf#1215
milespetrov pushed a commit to milespetrov/fgpv-vpgf that referenced this issue Sep 23, 2016
Currently $mdDialog does not support multiple dialogs at one time. Updated
focus manager to only close dialogs in WAITING state.

See [this angular material
issue](angular/material#8630)

Closes fgpv-vpgf#1215
@devversion
Copy link
Member

devversion commented Sep 26, 2016

Hello guys, just wanted to let you know, that multiple dialogs are right now supported, but not documented yet.

Using the multiple: true option, does ensure dialogs will not close the previous showing dialog.

@devversion devversion added P3: important Important issues that really should be fixed when possible. and removed in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs P2: required Issues that must be fixed. labels Sep 26, 2016
@jaymanned
Copy link

Great. Thanks. So it's now part of release 1.1.1?

@devversion
Copy link
Member

It will be available in the next release. Right now its only in master.

Frank3K pushed a commit to Frank3K/material that referenced this issue Oct 8, 2016
* feat(interimElement): properly handle multiple interims.

* Adds support for multiple interim elements (like dialog)
* When single interim (default) is enabled, then interims should hide properly (as in toasts).

Fixes angular#8624. References angular#8630.

* When hiding wait for currenlty opening interims

* Address EladBezalel's feedback

* Wait for interim element for cancel as well

* Address EladBezalel's feedback
devversion added a commit to devversion/material that referenced this issue Oct 30, 2016
* Add a brief documentation on how to show multiple dialogs at the same time.

* Adds the `multiple` option to the preset methods (as same as for the $$interimElement default preset)

Closes angular#8630.
@devversion devversion added the has: Pull Request A PR has been created to address this issue label Oct 30, 2016
ThomasBurleson pushed a commit that referenced this issue Nov 7, 2016
* Add a brief documentation on how to show multiple dialogs at the same time.

* Adds the `multiple` option to the preset methods (as same as for the $$interimElement default preset)

Closes #8630.
@warent
Copy link

warent commented Nov 29, 2016

Are we not able to use .multiple(true) on confirm dialogs?

@devversion
Copy link
Member

@warent You should be able to do that.

@michaelcode
Copy link

Hello. Is this option part of release 1.1.1 yet?

Thx for the good work

@trinvh
Copy link

trinvh commented Mar 23, 2017

@devversion Not works with confirm().multiple(true) on 1.1.1

@devversion
Copy link
Member

devversion commented Mar 23, 2017

@trinvh It doesn't work because it hasn't been released as part of v1.1.1.

The feature is included in v.1.1.2

@trinvh
Copy link

trinvh commented Mar 23, 2017

Well done @devversion

@njcaruso
Copy link

njcaruso commented Apr 5, 2017

This works for me:

var confirmDialog = $mdDialog.confirm({
multiple: true
});

$mdDialog.show(confirmDialog)

@richardanmmol
Copy link

Great! It worked for me.

@jainpiyush111
Copy link

jainpiyush111 commented Jul 27, 2017

I am not able to use $mdDialog.prompt({
multiple: true
});

what am i doing wrong ?

@njcaruso
Copy link

njcaruso commented Jul 27, 2017

@jainpiyush111 - I haven't tested on the prompt(), but on confirm() you would do it this way, which is probably very similar for prompt:

        var confirmDialog = $mdDialog.confirm()
            .title('Please confirm')
            .textContent('Are you sure you want to delete this message?')
            .ariaLabel('Delete confirmation dialog')
            .ok('Yes')
            .cancel('No')
            .multiple(true);

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

.. FYI - I'm on v1.1.3

@abheist
Copy link

abheist commented Sep 6, 2017

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('#parentDialog')))
            .ok('Yes')
            .cancel('No')
            .multiple(true);

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

skipHide for older versions & multiple for newer...

@okaiyong
Copy link

I am using 1.1.4 and this is my codes:
$mdDialog.show(
{ multiple: true, ..... }
);

It didn't work, any reason?

@njcaruso
Copy link

Not sure about your version, but I'm on 1.1.7 and it works well.

@okaiyong
Copy link

Thanks. Solved.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
- Lots of Comments has: Pull Request A PR has been created to address this issue P3: important Important issues that really should be fixed when possible. resolution: fixed type: enhancement
Projects
None yet
Development

No branches or pull requests