Skip to content

VirtualizedList passive event listener warning #2598

Closed

Description

@tienifr

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:

Activity

  1. changed the title [-][Violation] Added non-passive event listener to a scroll-blocking 'wheel' event[/-] [+]`VirtualizedList` passive event listener warning[/+] on Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions