clauderic / react-tiny-virtual-list

A tiny but mighty 3kb list virtualization library, with zero dependencies 💪 Supports variable heights/widths, sticky items, scrolling to index, and more!
https://clauderic.github.io/react-tiny-virtual-list/
MIT License
2.46k stars 166 forks source link

scrollToIndex and itemSize (caching?) issues #40

Closed giuseppeg closed 6 years ago

giuseppeg commented 6 years ago

Hi thanks for this awesome library!

I am experiencing an odd issue (possibly a bug). When using scrollToIndex and resizing a (vertical) list the row styles seem to be incorrect. Specifically height and top seem to be wrong.

I prepared a simple testcase for you to try out https://codesandbox.io/s/3wm42q716 When clicking the 💥 button the list resizes (itemSize changes) and the height of all rows up to the scrollToIndex are wrong.

Do you have any idea of what it is going on?

giuseppeg commented 6 years ago

When resetting this.lastMeasuredIndex to -1 here https://github.com/clauderic/react-tiny-virtual-list/blob/master/src/SizeAndPositionManager.ts#L88 it works obviously

clauderic commented 6 years ago

Hmm, looks like a legitimate issue, would you care to send a PR that fixes this? 😄

giuseppeg commented 6 years ago

@clauderic I just realized that I completely forgot to reply to your last question, I am sorry about that. Thank you so much for taking the time to fix this <3