material icon indicating copy to clipboard operation
material copied to clipboard

toast: toasts should always be displayed in the visible viewport

Open ilanbiala opened this issue 11 years ago • 59 comments

Toasts should ideally be visible no matter where I am on the screen if I give no container element and set the position to one of the corners. Thoughts on setting it to position: fixed; in this case?

ilanbiala avatar Jan 04 '15 22:01 ilanbiala

@ilanbiala I think it might be how it is now so that it can bump the md-fab buttons up a bit when it opens.

Also it moves correctly when I scroll are you sure you're using md-content correctly? If so could you please make a plunker so we can confirm this.

epelc avatar Jan 07 '15 18:01 epelc

I'm looking into a good solution for this. The reason that a simple position fixed doesn't work is because, what if there's a fab button? What if there's a toolbar?

I'll be looking into a good solution for 0.7.1

rschmukler avatar Jan 08 '15 23:01 rschmukler

To me it seems the toast scrolling around is much more broken than it eclipsing a FAB or toolbar for a few seconds. Toast is used for short-term important things we definitely want the user to see.

dguralnick avatar Feb 13 '15 19:02 dguralnick

I'd rather wait for a better fix. If a toast goes over a fab it will be hard to read anyways so it hardly seems better than the current situation.

I'd say just apply the position:fixed locally if you prefer that.

epelc avatar Feb 13 '15 20:02 epelc

Pseudo code implementation for toast onShow... for future reference

onShow() {
  var fabs = document.querySelectorAll('md-fab');
  var intersectingFabs = fabs.filter(willIntersect);
  options.intersectingFabs = intersectingFabs;

  angular.forEach(intersectingFabs, function(el) {
    el.classList.add('md-toast-intersecting') // transition animation
    if (position.indexOf('top') != -1) el.classList.add('md-toast-enter-from-top'); // set position accordingly
  })

  var toolbars = document.querySelectorAll('md-toolbar');
  var intersectingToolbars = toolbars.filter(willIntersect);  
  if (intersectingToolbars.length) {
    element.addClass('md-with-toolbar') // change position relatively
    element.style.top = calculateOffsetToNotIntersect(element, intersectingToolbars[0]);
  }

}

rschmukler avatar Apr 02 '15 16:04 rschmukler

Agree, toasts should be always visible. +1

gio82 avatar Apr 29 '15 09:04 gio82

+1

Hrafnkellos avatar May 13 '15 16:05 Hrafnkellos

+1

Jarema avatar Jun 30 '15 12:06 Jarema

I'm on the 'always show' team. Suppose you have two fab buttons, user is about to click the bottom one, then a toast pushes them both down and the click the wrong one.. Buttons shouldn't move around unexpectedly.

I just edited my angular-material.js file: line 11979 'md-' -> 'md-fixed-'

then in my css

md-toast {
    z-index: 10000;
}
.md-fixed-top {
    position: fixed;
    top: 66px; // size of my navbar + 16px
}

.md-fixed-right {
    position: fixed;
    right: 16px;
}

... etc for left/bottom

charliewynn avatar Jun 30 '15 15:06 charliewynn

@ThomasBurleson @rschmukler @robertmesserle can we get some discussion going to resolve this? As of now, If I am in the center of a scrollable page, no matter where I put the toast I won't see it, which defeats the purpose of the toast. Is there a better option than position fixed?

ilanbiala avatar Jul 16 '15 14:07 ilanbiala

The Team's concern is still this:

  • The reason that a simple position fixed doesn't work is because, what if there's a fab button?
  • What if there's a toolbar?

ThomasBurleson avatar Jul 16 '15 23:07 ThomasBurleson

@ThomasBurleson

Things that pop up seemingly randomly to the user shouldn't move clickable buttons -> have the toast overlap FABs you don't want to cause http://i.imgur.com/C0biWU3.gif

For toolbars, pick a default, users can override it in their css if they need to

charliewynn avatar Jul 17 '15 13:07 charliewynn

@charliewynn - Please read the Material Specifications for Toast

ThomasBurleson avatar Jul 17 '15 15:07 ThomasBurleson

@ThomasBurleson If we're strictly following the spec then

"Toasts are similar to snackbars but do not contain actions" and it implies that toasts should only animate from the bottom

I know my suggestion isn't perfect.. but it is so much better than showing toasts off-screen

charliewynn avatar Jul 17 '15 15:07 charliewynn

Just chiming in, for my application I have an md-toolbar on top of which the toast appears. I am ok with that as long as it sits on top of anything that is there, instead of moving that elements position.

Also, as my page is scrollable, any info I wish to show to the user via the toast becomes useless as the toast is not visible when the user has scrolled to the middle of the page.

Setting the toast to appear at the bottom also causes issue reported in #2936

Fixing the position seems currently the better option unless someone can suggest something better. Cheers!

vigneshdv avatar Jul 17 '15 18:07 vigneshdv

@ThomasBurleson how was this resolved? Are toasts position: fixed now?

ilanbiala avatar Jul 21 '15 17:07 ilanbiala

Toasts are position:absolute; If scrolling presents an issue, then perhaps we should auto-hide toasts on scroll events.

ThomasBurleson avatar Jul 21 '15 17:07 ThomasBurleson

@ThomasBurleson Is that the final resolution for this issue? If you hide a toast on scroll events, then what happens if I show a toast while a user is scrolling...He won't see it, but I don't know that.

ilanbiala avatar Jul 21 '15 19:07 ilanbiala

@ilanbiala - let's reopen this for now. But it definitely is a lower priority issue... as we are focused on triage and delivery of v1.0.

ThomasBurleson avatar Jul 21 '15 19:07 ThomasBurleson

Ok. Just to get some more information and maybe to allow one of us to propose a solution, what are you guys currently thinking about other than covering toolbars and FABs? What are the alternatives as of now?

ilanbiala avatar Jul 21 '15 20:07 ilanbiala