-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix __addScrollListeners for polyfilled browsers #263
Fix __addScrollListeners for polyfilled browsers #263
Conversation
@valdrinkoshi I would recommend you to set up your editor to auto-trim trailing whitespaces, e.g. the setting for VS Code: https://stackoverflow.com/a/30884298/1331425 For now, it'd be easier to do CR with whitespaces diff disabled: https://github.com/PolymerElements/iron-overlay-behavior/pull/263/files?w=1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @limonte thanks for the contribution!
It's not clear what issue the current implementation is creating, mind filing it so we can discuss it? I tried skimming through predixdesignsystem/px-data-grid#331, but couldn't understand the scenario: looks like the problem is that with ShadyDOM we trigger twice the __onCaptureScroll
, but not clear to me why is that a problem.
Also, this PR needs a test to avoid future regressions.
I left some comments to the current implementation in the meantime 👌
iron-overlay-behavior.html
Outdated
@@ -645,7 +645,7 @@ | |||
this.__rootNodes = []; | |||
// Listen for scroll events in all shadowRoots hosting this overlay only | |||
// when in native ShadowDOM. | |||
if ('attachShadow' in Element.prototype && 'getRootNode' in Element.prototype) { | |||
if (!window.ShadyDOM && 'attachShadow' in Element.prototype && 'getRootNode' in Element.prototype) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't be compatible with polymer 1.x (as it depends on webcomponents v0 which is not implemented with ShadyDOM
). This whole check could be replaced with:
if (Polymer.Settings.useShadow) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍
scrollable = f.$.scrollable; | ||
overlay = f.$.overlay; | ||
}); | ||
if (!window.ShadyDOM) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of having this if
wrapping the whole suite, you can use suiteSetup
and skip the whole suit:
suite('scroll actions in shadow root', function() {
suiteSetup(function() {
if (!Polymer.Settings.useShadow) {
this.skip();
}
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍
|
||
suite('scroll actions in shadow root, overlay distributed', function() { | ||
suite('scroll actions in shadow root, overlay distributed', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, you can use suiteSetup
suite('scroll actions in shadow root, overlay distributed', function() {
suiteSetup(function() {
if (!Polymer.Settings.useShadow) {
this.skip();
}
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍
In What happens here is basically that scroller component stops firing
I'm not sure what should I test in this case, could you please help me with the idea how to perform the test? Thanks a lot for the quick and great feedback! |
I tried install the version in master and play with it locally: I noticed that the scroll is not blocked when I scroll with the trackpad (not with the scroll handler, through the pointer). I think that should be locked no matter what, so there seems to be something going on with scroll handling there. It would be helpful to have a smaller repro, e.g. this doesn't happen in the demo page of iron-overlay-behavior https://www.webcomponents.org/element/PolymerElements/iron-overlay-behavior/demo/demo/index.html |
There's actually no handling there, because there's nothing to handle, |
My understanding is that you want Currently, For any other custom behavior, consider toggling |
Even after adding |
oh! This is a bug of ShadyDOM, where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even when webcomponents/shadydom#190 will be fixed, I still think this PR would make iron-overlay-behavior more performant by avoiding to add scroll event listeners when those are not needed.
I don't think there is an easy way to write a test for this, so I'll merge it as is.
Thanks @limonte again for guiding me through the scenario and your contribution 👍
Thanks for your prompt review @valdrinkoshi! Can we expect the patch release of |
right, 2.3.2 released 👌 |
The comment above the line I changed says:
It's not possible to detect the native ShadowDOM by checking only
'attachShadow' in Element.prototype && 'getRootNode' in Element.prototype
: