material icon indicating copy to clipboard operation
material copied to clipboard

md-select interferes with the window scroll listener

Open PrashantAshok opened this issue 11 years ago • 7 comments

I created a jsFiddle. I have a sticky nav on scroll. If you click the select dropdown at the bottom of the page, since it removes the scroll bar, it messes (hides) the navigation bar at the top.

On a quick glance, it looks like the md-virtual-scroll-container with md-virtual-scroller is wrapping the entire content inside <body>, hence hiding the scrollbar. I thought wrapping the md-select with md-content might help but it didn't make any difference.

Any thoughts?

PrashantAshok avatar May 05 '15 21:05 PrashantAshok

Same problem here, also, updating dom path seems dangerous, it can break css rules and other js behaviors. Why is this necessary ?

myagoo avatar May 06 '15 08:05 myagoo

+1

whoknows avatar May 06 '15 08:05 whoknows

I think I found the problem in the code. In util.js, I am not sure the need for checking $document[0].body.scrollTop || $document[0].documentElement.scrollTop. Just checking if the lastParent is defined or not should suffice. Something like

if (!disableTarget) {
    if (!lastParent) {
        disableTarget = angular.element($document[0].body);
    } else {
        disableTarget = angular.element(lastParent);
    }
}

I did a quick test in Chrome/FF/IE - it seems to be working.

PrashantAshok avatar May 06 '15 23:05 PrashantAshok

@PrashantAshok can you check the latest source from master and see if your issue still persists? It does still break your jsfiddle, but I imagine that if we added a md-scroll-disabled class to the body element you could probably style your sticky header appropriately. Here is a link to your updated fiddle. Let me know your thoughts.

rschmukler avatar May 19 '15 22:05 rschmukler

@rschmukler - thanks. Looks great now, that the body is not being wrapped. But the issue still persists.

there is a minor issue, in util.js, shouldn't the check be >= rather than just >? Or am I missing something?

I had to make that change along with wrapping the md-select with md-content, Updated jsFiddle. Then works perfectly.

PrashantAshok avatar May 20 '15 17:05 PrashantAshok

An element's scrollHeight is always equal to its offsetHeight unless it is scrolling, in which case it is greater than it. So, in the case of isScrolling() we want to return true only if >.

The reason that your fiddle works with it that way is because it's not actually disabling the scrolling :) You can see that it's possible to scroll.

rschmukler avatar May 20 '15 19:05 rschmukler

Make sense. Oh, sorry didn't notice that. What's md-scroll-disabled class?

But if we try to remove scroll (bar), it would mess up the scroll listeners/offset calculations. Or did you have something other in mind?

(Apologies for a bit complicated fiddle, a simpler fiddle is here - Scroll down a bit and then click select).

PrashantAshok avatar May 28 '15 20:05 PrashantAshok