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

Bug: Scroll event listener should be passive #996

Closed
gregor-mueller opened this issue May 24, 2023 · 2 comments · Fixed by #1127
Closed

Bug: Scroll event listener should be passive #996

gregor-mueller opened this issue May 24, 2023 · 2 comments · Fixed by #1127

Comments

@gregor-mueller
Copy link

The scroll event listener on the table is not passive, resulting in unwanted behaviour:

  1. Chrome (and possibly other browsers) throw a warning in the console.
  2. Sometimes scrolling is interrupted (I can scroll to the right in some tables but when I scroll left, it stops and the back gesture is triggered on MAC, resulting in unwanted page navigation).

The culprit is the following line, as far as I can see:

https://github.com/react-component/table/blob/ff93e234f76f8ad5b8c6ce90855ba4d4db5e627a/src/FixedHolder/index.tsx#LL90C42-L90C42

It should be fixed with this change:

-    scrollRef.current?.addEventListener('wheel', onWheel);
+    scrollRef.current?.addEventListener('wheel', onWheel, {passive:true});

It's broadly supported:
https://caniuse.com/passive-event-listener

For better backwards compatibility, a check for the support of the option can be added like in this example:
https://github.com/RByers/rbyers.github.io/blob/master/scroll-latency.js#L95-L104

@santosh1994
Copy link

any updates on this issue?

@santosh1994
Copy link

Alternatively we can apply this css rule on table to disallow gestures on table

Sometimes scrolling is interrupted (I can scroll to the right in some tables but when I scroll left, it stops and the back gesture is triggered on MAC, resulting in unwanted page navigation).

touch-action: none;

https://developer.mozilla.org/en-US/docs/Web/CSS/touch-action

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

Successfully merging a pull request may close this issue.

2 participants