question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Click events not always registering for Rows when scrolling fast

See original GitHub issue

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!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
chrisnojimacommented, Feb 12, 2019

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

0reactions
heyimalexcommented, Feb 4, 2019

@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 onScroll callback, and attaches an onClick handler to a container div that calculates the item under the cursor.

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

android - Click event during scrolling of LazyRow not registered
I have 2 LazyRows and a button. During scrolling of LazyRow A, I can click on the button without a problem, but when...
Read more >
Be Slightly Careful with Sub Elements of Clickable Things
Sometimes if you need 1000 click events on table rows it's better to have one single event with delegation (you don't have to...
Read more >
Smooth Scrolling in Excel for Windows
First, it's smoother during the scroll when using either the mouse wheel* or the scrollbars (touch screen and touch pad already scrolled ...
Read more >
Document: scroll event - Web APIs - MDN Web Docs - Mozilla
The scroll event fires when the document view has been scrolled. To detect when scrolling has completed, see the Document: scrollend event.
Read more >
Handling Events :: Eloquent JavaScript
If a button inside a paragraph is clicked, event handlers on the paragraph ... was clicked, rather than register individual handlers on all...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found