react-select icon indicating copy to clipboard operation
react-select copied to clipboard

non-passive event listener in scroll blocking events

Open gugurete opened this issue 8 years ago • 24 comments

chrome warnings popping up about non-passive event listeners

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

[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

gugurete avatar Jun 19 '18 23:06 gugurete

hello @gugurete thanks for raising this, which version of react-select are you using? Could you also supply us with a codesandbox with your select configuration, just so we can debug/ reason about this a bit easier.

gwyneplaine avatar Jun 20 '18 02:06 gwyneplaine

It is version: 2.0.0-beta.6, and the offending code is in react-select.es.js starting with line 564 I believe it should be something like el.addEventListener('wheel', this.onWheel, {passive: true}); to avoid chrome warning messages.

key: 'startListening',
value: function startListening(el) {
  // bail early if no scroll available
  if (el.scrollHeight <= el.clientHeight) return;

  // all the if statements are to appease Flow 😢
  if (typeof el.addEventListener === 'function') {
    el.addEventListener('wheel', this.onWheel, false);
  }
  if (typeof el.addEventListener === 'function') {
    el.addEventListener('touchstart', this.onTouchStart, false);
  }
  if (typeof el.addEventListener === 'function') {
    el.addEventListener('touchmove', this.onTouchMove, false);
  }
}

gugurete avatar Jun 20 '18 05:06 gugurete

https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md

gugurete avatar Jun 20 '18 05:06 gugurete

I am getting the same warnings on Chrome with "react-select 2.0.0-beta.7":

Added non-passive event listener to a scroll-blocking 'wheel' event. Added non-passive event listener to a scroll-blocking 'touchstart' event. Added non-passive event listener to a scroll-blocking 'touchmove' event.

ziikki avatar Aug 09 '18 13:08 ziikki

Same problem with react-select 2.0.0, Chrome version is 68.0.3440.106 (64-bit)

xakep139 avatar Aug 15 '18 01:08 xakep139

@gugurete looks good, would you mind submitting a PR?

jossmac avatar Aug 15 '18 02:08 jossmac

@jossmac FYI: #2933

xakep139 avatar Aug 15 '18 04:08 xakep139

Re-opened due to #2940

Having non-passive listeners for ScrollCaptor may be unavoidable, but needs further consideration.

jossmac avatar Aug 16 '18 04:08 jossmac

I'm still having this issue, any update on it?

Ericnr avatar May 07 '19 00:05 Ericnr

I'm having the same issue as well. react-select: 3.0.4 Chrome: 74.0.3729.169

misarfraz avatar Jun 19 '19 19:06 misarfraz

Still happening to me!

chrisnorwood avatar Oct 17 '19 00:10 chrisnorwood

I'm having the same issue as well. react-select: 3.0.4 Chrome: 74.0.3729.169

same issue for me on

react-select: 3.0.8 Chrome: 78.0.3904.108

jeltehomminga avatar Dec 16 '19 11:12 jeltehomminga

Same here! react-select:3.0.8 Chrome for macOS: Version 79.0.3945.117 (Official Build) (64-bit)

tainefreitas avatar Jan 14 '20 21:01 tainefreitas

The cause is the flag "menuIsOpen" in my case. About this tag, I have other problem (when I go back home, I create the issue and link here): I have multiple components in the page, but somehow always goes to the end of the page, where's the react-select is, and when I deactivate the flag, all the problems goes away...

tainefreitas avatar Jan 16 '20 21:01 tainefreitas

I have the same problem when I click for open or set menuIsOpen = true. I'm using the last version.

image

danielanjos avatar Aug 29 '20 21:08 danielanjos

I have the same problem when I click for open or set menuIsOpen = true. I'm using the last version.

image

Same here!! react-select: 3.1.0 chrome: Version 84.0.4147.135 (Official Build) (64-bit)

b3rg3t avatar Sep 02 '20 07:09 b3rg3t

Same problem here. When I click to open menu which has items for scrolling. Using the latest version. React-select: 3.1.0 Chrome ver: 86.0.4240.75 (Official Build) (64-bit) image

dqtkien avatar Oct 09 '20 07:10 dqtkien

~~I've started a fork of react-select. Feel free to resubmit this issue on the fork and/or submit a PR to resolve this issue on the fork and we can get it merged and released.~~

EDIT: :tada: I've archived the fork now that we've got some momentum in this repo and Jed is involved again. Sorry for the disturbance!

Methuselah96 avatar Nov 14 '20 16:11 Methuselah96

Any solution yet?

sgarchavada avatar Jan 07 '21 07:01 sgarchavada

This appears for me as well now with every mount/unmount of the Menu.

There appear to be some use cases that we want to interrupt scrolling, but these might be conditional so that we could potentially use the passive event listener. I think this would certainly be worth investigating.

ebonow avatar Jan 07 '21 17:01 ebonow