Skip to content
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

Google Chrome Violation: Added non-passive event #164

Closed
aletheia7 opened this issue Mar 12, 2021 · 3 comments
Closed

Google Chrome Violation: Added non-passive event #164

aletheia7 opened this issue Mar 12, 2021 · 3 comments

Comments

@aletheia7
Copy link

Google Chrome Console Error

[Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952

macOS: Big Sur
Google Chrome: 89.0.4389.82
iro.js: v5.3.2

iro.js line 14
iro.js chrome formatted: line 241

Code

... u ? (t || n.addEventListener(l, T, e), ...
l = onmousedown
e = false
e should probably be { passive: true }

also
l = ontouchstart
e = false

https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener

@jaames
Copy link
Owner

jaames commented Mar 12, 2021

I intentionally mark them as non-passive: https://github.com/jaames/iro.js/blob/master/src/ComponentWrapper.tsx#L83 , since they call preventDefault() to stop the page from scrolling while users drag the color picker handles

The error isn't fatal, it's just a minor warning since most people don't have any reason to use touch events in this way

@jaames jaames closed this as completed Mar 12, 2021
@aletheia7
Copy link
Author

When I sent a breakpoint, e is a boolean. e is not an object with passive set to false.

Would the Violation disappear if e was {passive: false} ?

@jaames
Copy link
Owner

jaames commented Mar 12, 2021

Ah, looks like that code is coming from Preact, so not sure if there's anything I can do about that.

Relevant Preact issue:
preactjs/preact#428

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants