Skip to content

getTotalSize() returns 0 when using multiple lanes with a single item #963

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

Closed
2 tasks done
greenblues1190 opened this issue Mar 24, 2025 · 2 comments · Fixed by #964 or #967
Closed
2 tasks done

getTotalSize() returns 0 when using multiple lanes with a single item #963

greenblues1190 opened this issue Mar 24, 2025 · 2 comments · Fixed by #964 or #967

Comments

@greenblues1190
Copy link
Contributor

Describe the bug

Starting from version 3.13.3, the behavior of virtualizer.getTotalSize() has changed. When using multiple lanes (i.e., lanes > 1) and the item count is 1, getTotalSize() now returns 0.
This did not happen in 3.13.2, where the total size of a single item was calculated and returned correctly.

If this change in behavior is intentional, please let me know.

Your minimal, reproducible example

https://stackblitz.com/edit/tanstack-virtual-4zlr1xau

Steps to reproduce

  1. start app npm install && npm run start
  2. variable settings
    • @tanstack/react-virtual version: 3.13.2
    • lanes: 2
    • contents count: 1
  3. change VERSION(main.tsx#L8) to "3.13.3" and observe that the same setup returns the expected item size.

Expected behavior

with count === 1 and lanes > 1, getTotalSize() should return the size of the single item, not 0.

How often does this bug happen?

Every time

Screenshots or Videos

2025-03-24.2.11.38.mov

Platform

  • OS: macOS 13.3.1 22E261 arm64
  • Browser: Chrome 134.0.6998.89 (arm64)

tanstack-virtual version

v3.13.3

TypeScript version

No response

Additional context

No response

Terms & Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
@soren121
Copy link
Contributor

Sorry, that's my bug! Pretty obvious now that I see it. Thanks @Ryanromaris for fixing it :)

@greenblues1190
Copy link
Contributor Author

greenblues1190 commented Mar 28, 2025

The issue seems to still occur in 3.13.5 when there's only one item and multiple lanes. I've submitted a follow-up PR to address this: #967

Would appreciate a review when you get a chance!

reproduce: https://stackblitz.com/edit/tanstack-virtual-4zlr1xau?file=src%2Fmain.tsx

resolved

greenblues1190 added a commit to greenblues1190/virtual that referenced this issue Mar 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants