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

VirtualizedList passive event listener warning #2598

Open
1 task done
tienifr opened this issue Oct 18, 2023 · 0 comments
Open
1 task done

VirtualizedList passive event listener warning #2598

tienifr opened this issue Oct 18, 2023 · 0 comments
Labels

Comments

@tienifr
Copy link
Contributor

tienifr commented Oct 18, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Describe the issue

Passive event warning [Violation] Added non-passive event listener to a scroll-blocking 'wheel' event appears when using VirtualizedList. Happens on Chrome 51 or later which support passive event listener.

Expected behavior

The passive event warning does not appear.

Steps to reproduce

  1. Use a VirtualizedList component
  2. Observe the warning in Chrome 51 or later

Test case

https://codesandbox.io/s/summer-dew-txtgt2

Additional comments

image

Proposed solution

Root cause

We're not using passive options for performance improvement when adding listener for the wheel event here:

this._scrollRef.getScrollableNode().addEventListener('wheel',
this.invertedWheelEventHandler
);

Solution

  1. Add passive: true to wheel event listener with passive event feature detection in order not to collide with capture option
  2. Remove event preventDefault in the listener here:

@tienifr tienifr added the bug label Oct 18, 2023
@tienifr tienifr changed the title [Violation] Added non-passive event listener to a scroll-blocking 'wheel' event VirtualizedList passive event listener warning Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant