Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

[Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event #4460

Closed
gertcuykens opened this issue Feb 27, 2019 · 5 comments · Fixed by #4747
Closed

Comments

@gertcuykens
Copy link

gertcuykens commented Feb 27, 2019

chrome example: https://output.jsbin.com/fotedog

https://jsbin.com/fotedog/edit?html,output

probably related to #629

Not sure how to fix it

image

image

@acdvorak
Copy link
Contributor

Thanks for bringing this to our attention!

We'll need to update the component's default adapter implementation to pass {passive: true} as the third parameter to addEventListener() in supported browsers:

private getInputAdapterMethods_(): MDCTextFieldInputAdapter {
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
return {
getNativeInput: () => this.input_,
isFocused: () => document.activeElement === this.input_,
registerInputInteractionHandler: (evtType, handler) => this.input_.addEventListener(evtType, handler),
deregisterInputInteractionHandler: (evtType, handler) => this.input_.removeEventListener(evtType, handler),
};
// tslint:enable:object-literal-sort-keys
}

It looks like a number of components listen to touchstart events: ripple, select, slider, textfield, and tab-bar-scroller. So we might want to extract the applyPassive() function from ripple util and move it to mdc-dom:

export function applyPassive(globalObj: Window = window, forceRefresh = false):
boolean | EventListenerOptions {
if (supportsPassive_ === undefined || forceRefresh) {
let isSupported = false;
try {
globalObj.document.addEventListener('test', () => undefined, {
get passive() {
isSupported = true;
return isSupported;
},
});
} catch (e) {
} // tslint:disable-line:no-empty cannot throw error due to tests. tslint also disables console.log.
supportsPassive_ = isSupported;
}
return supportsPassive_ ? {passive: true} as EventListenerOptions : false;
}

@moog16 moog16 added this to the Sprint May 3rd milestone Apr 22, 2019
@moog16 moog16 self-assigned this May 8, 2019
@moog16
Copy link
Contributor

moog16 commented May 8, 2019

I'm no longer seeing this issue in our screenshot tests, unit tests, or in the jsbin provided. Is this something we should still fix?

@gertcuykens
Copy link
Author

When you refresh the page it still happens, why you need to refresh I don't know.

image

@abhiomkar
Copy link
Collaborator

I'm able to reproduce this, the log level should be set to verbose.

@moog16
Copy link
Contributor

moog16 commented May 21, 2019

I see this with verbose as well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
5 participants