material icon indicating copy to clipboard operation
material copied to clipboard

$mdDialog not filling the full page

Open CToner3223 opened this issue 11 years ago • 5 comments

I'm trying add some md-dialogs into my app using the $mdDialog service. I've found that the dialog only fills part of the screen.

I have a plunker that demonstrates the issue, http://plnkr.co/edit/ZdiCBxZhEKAv47oYa57F?p=preview

Scroll down to the bottom of the page and click the Show Dialog button and hopefully you'll see what I'm talking about.

I'm not sure if its an issue with material or if its just me not knowing how to use it but any help would be appreciated.

CToner3223 avatar Dec 11 '14 11:12 CToner3223

It may be because of the absolute heights. At first I thought it had to do with the dialog being added to the inner div instead of the body but that wasn't the issue also using md-content instead changed nothing. I also switched to the latest version of angular(1.3.6) just in case that had something to do with it.

http://plnkr.co/edit/tjpSmzCpHvdQIhPQ4PVt?p=preview

epelc avatar Dec 11 '14 17:12 epelc

Fixed with 993fa2bc00598dd18227b12bb197f2d9c667ea75

rschmukler avatar Jan 13 '15 17:01 rschmukler

Not quite fixed yet. $mdDialog should overlay the currently visible screen, no matter how far the user scrolled, and not attach itself to the top.

Updated plunker with git libraries demonstrating the issue: http://plnkr.co/edit/FmBGZ3G0Y71vh0z7Ffrm?p=preview

With this commit it may be even worse - scroll down to the second button and you basically locked yourself out, since scrolling is disabled. (Escape works, but still).

SebiH avatar Jan 13 '15 19:01 SebiH

I ran into this issue with a custom directive I'd created that makes use of the dialog logic. A quick fix is to set the dialog's css top to the current viewport scroll position, i.e. $window.scrollY and to do the same for the md-backdrop. If you're working with the dialog src, something like:

dialogEl.css({ top: $window.scrollY });
options.backdrop.css({ top: offsetY });

You then need to change the md-backdrop css from:

lv-backdrop {
  z-index: 50;
  background-color: rgba(0, 0, 0, 0);
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
}

to:

lv-backdrop {
  z-index: 50;
  background-color: rgba(0, 0, 0, 0);
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

Anyway, that should probably be done internally by the dialog service at some point anyway for precisely this reason. Note that this only fixes the issue when the dialog is set to disableParentScroll: true, since the backdrop will only cover the exact dimensions of the viewport for the current scroll position.

levbrie avatar Jan 13 '15 20:01 levbrie

Actually, in order to maintain the ability to clickOutsideToClose, it's better to also change:

.md-dialog-container {
  display: flex;
  justify-content: center;
  align-items: center;
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: $z-index-dialog;
}

to:

.md-dialog-container {
  display: flex; justify-content: center;
  position: absolute; align-items: center;
  left: 0; top: 0;
  width: 100%; height: 100%;
  z-index: $z-index-dialog;
}

and to then set this element's top (along with the backdrop's top) to the viewportScrollPosition, rather than setting the md-dialog element, which will position the dialog correctly but will not position its container, which is needed for the click event registered to close the dialog.

levbrie avatar Jan 13 '15 21:01 levbrie