T
TanStackβ€’2y ago
correct-apricot

[Possible Bug] getTotalSize is calculated incorrectly.

I have a waterfall style of grid with 4 lanes and each item can be a different height. I have the calculations correct but sometimes at the bottom content gets cut off. I was banging my head against the wall but then I realized there might be a bug and just wanted to confirm. You can see the list of measurements in the image. You can see index 16 as an end that is bigger than index 17, but getTotalSize() only takes the last item of the array into consideration. This is taken straight from the source:
getTotalSize = () =>
(this.getMeasurements()[this.options.count - 1]?.end ||
this.options.paddingStart) -
this.options.scrollMargin +
this.options.paddingEnd
getTotalSize = () =>
(this.getMeasurements()[this.options.count - 1]?.end ||
this.options.paddingStart) -
this.options.scrollMargin +
this.options.paddingEnd
Shouldn't this fin the biggest end value and use that instead of just presuming the last element? Just trying to confirm that this is a bug in the logic. Thank you!
No description
6 Replies
correct-apricot
correct-apricotOPβ€’2y ago
FWIW: After I patched node_modules, I saw the correct behavior πŸ™‚ I am happy to make a PR presuming this is the reason why I was getting weird issues @Maintainer just trying to get traction here
fascinating-indigo
fascinating-indigoβ€’2y ago
Hey just as a heads up you just pinged every maintainer of every TS project πŸ˜… Including those (like myself) that aren't familiar with the Virtual codebase. Generally you want to avoid pinging people like this πŸ˜‰
correct-apricot
correct-apricotOPβ€’2y ago
Oh jeez I’m so sorry I don’t use discord much 😭😭 I really apologize for the unnecessary ping
rare-sapphire
rare-sapphireβ€’2y ago
I am happy to make a PR presuming this is the reason why I was getting weird issues
please do, ping me after and will see what is going there, thanks
correct-apricot
correct-apricotOPβ€’2y ago
PR: https://github.com/TanStack/virtual/pull/660 @piecyk Let me know what you think πŸ™‚
GitHub
Bug Fix: Calculate getTotalSize correctly when using multiple lanes...
In my application I have a waterfall style layout so the last item is not guaranteed to be the furthest away. I was having issues with the sizing not being correct, so after digging in I found the ...
rare-sapphire
rare-sapphireβ€’2y ago
thanks

Did you find this page helpful?