-
-
Notifications
You must be signed in to change notification settings - Fork 792
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
Click events not always registering for Rows when scrolling fast #128
Comments
This library intentionally disables To my knowledge, this is still commonly done to improve performance (although admittedly it has been a while since I've looked into this so it's possible things have changed– in which case, I'd welcome any updated resources you may have). For the time being though, I'm going to close this issue as I don't plan on changing the current behavior. We can continue to chat here though if you have more ideas or questions. 😄 |
I should add that I currently reset the is-scrolling state after a 150ms delay so the window of time in which a click event is not handled should be small. |
Thank you @bvaughn! I actually found the same info yesterday looking through the Could this maybe be documented somewhere? Or even better the ability to disable the behavior using a prop on the Also regarding performance, in my case I did not really notice any decrease in performance after overriding pointerEvents so the fix is working great. I do occasionally still hit it if the item is slow to render, in that case a virtualized onClickItem or something on the list could present a possible fix since it should in theory be able to calculate which item should be clicked based on offset and row height right? Thanks again! |
I don't think I want to add a prop to override this behavior, because those one-off props bloat the library and make maintenance more difficult. Have a Code Sandbox or something showing your workaround? Maybe I could add it to the FAQs or something.
That's sort of an interesting idea. If you'd like to put up a PR, I'd be happy to review it. (No promises it would land– depends on complexity and size.) |
The workaround is basically just this:
A first step would be to just add it to the FAQ I guess (in |
Cool, thanks. :) PRs to the README are always welcome too~ |
Sure thing, will look into it :D |
@johot Here's a codesandbox that kinda does what you were talking about with the virtualized onClick but outside of the library. I didn't think too hard about it but it seems to work? It tracks scroll position through the Edit: I'm dumb, this needs to take into account the container position, so an actual working impl also needs a ref on the container and to use getBoundingClientRect. |
Just want to chime in that I just got a bug report about this in our app and am now applying this as a workaround |
It's now the end of 2023, and I've encountered the exact same issue. I've spent many hours trying to optimize my code, and now I know that simply setting pointerEvents to 'auto' was all that was needed :). If I had pushed the changes with ignoring events during fast scrolling, someone would surely have reported it as a bug. @johot Thanks for the workaround :) |
Glad to have helped! 😊 |
[`react-window` disables `pointerEvents` while scrolling meaning you can't click anything while scrolling.](bvaughn/react-window#128). This means that the first click when you stop the scroll with inertial scrolling doesn't get registered. This is suuuper annoying. This might make sense when you click to stop on a more intentional UI but it doesn't makes sense in a list like this because we eagerly click things even on mousedown. This PR just override that to re-enable pointer events. Supposedly this is done for performance but that might be outdated knowledge. I haven't observed any difference so far. If we discover that it's a perf problem, there's another technique we can use where we call `ownerDocument.elementFromPoint(e.pageX, e.pageY)` and then dispatch the event against that element. But let's try the simplest approach first?
[`react-window` disables `pointerEvents` while scrolling meaning you can't click anything while scrolling.](bvaughn/react-window#128). This means that the first click when you stop the scroll with inertial scrolling doesn't get registered. This is suuuper annoying. This might make sense when you click to stop on a more intentional UI but it doesn't makes sense in a list like this because we eagerly click things even on mousedown. This PR just override that to re-enable pointer events. Supposedly this is done for performance but that might be outdated knowledge. I haven't observed any difference so far. If we discover that it's a perf problem, there's another technique we can use where we call `ownerDocument.elementFromPoint(e.pageX, e.pageY)` and then dispatch the event against that element. But let's try the simplest approach first? DiffTrain build for commit facebook@06d0b89.
[`react-window` disables `pointerEvents` while scrolling meaning you can't click anything while scrolling.](bvaughn/react-window#128). This means that the first click when you stop the scroll with inertial scrolling doesn't get registered. This is suuuper annoying. This might make sense when you click to stop on a more intentional UI but it doesn't makes sense in a list like this because we eagerly click things even on mousedown. This PR just override that to re-enable pointer events. Supposedly this is done for performance but that might be outdated knowledge. I haven't observed any difference so far. If we discover that it's a perf problem, there's another technique we can use where we call `ownerDocument.elementFromPoint(e.pageX, e.pageY)` and then dispatch the event against that element. But let's try the simplest approach first? DiffTrain build for [06d0b89](facebook@06d0b89)
So I have created a basic ListBox using
react-window
and everything is rendering great!One problem I have however is that if I scroll the list and right after scrolling click on an item it's click handler (a
div
in this case) is not always invoked.My guess is that I click before the item has been properly rendered and placed on the screen. Does this sound plausible?
Maybe if the
FixedSizeList
could have it's own click handler that could calculate which items should have been clicked in case it has not been rendered fully yet?Is there any strategy or workaround for these kinds of problems? Is it a known issue?
Thanks for a great library!
The text was updated successfully, but these errors were encountered: