virtual icon indicating copy to clipboard operation
virtual copied to clipboard

Layout breaks when changing lanes option with measureElement used

Open kruchininfl opened this issue 6 months ago • 0 comments

Describe the bug

When using measureElement with useVirtualizer, changing the number of lanes dynamically causes the layout to break.
The virtualizer calculates incorrect ranges for items with indices beyond the visible range, resulting in mispositioned items or empty spaces.

Your minimal, reproducible example

https://codesandbox.io/p/devbox/tankstack-virtual-range-extractor-forked-wlddzn?workspaceId=ws_NvUKNhUDiFBCs4Fb9Zkkhb

Steps to reproduce

  1. Scroll to the end of the list (so that only higher-index items are rendered).
  2. Change the number of lanes from 10 to 5 dynamically.

Expected behavior

  • The virtualizer should correctly invalidate cached measurements for all items and recalculate their positions when the number of lanes changes.
  • The layout should adjust seamlessly after changing lanes.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

Any platform

tanstack-virtual version

3.13.12

TypeScript version

5.2.2

Additional context

No response

Terms & Code of Conduct

  • [x] I agree to follow this project's Code of Conduct
  • [x] 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.

kruchininfl avatar Jul 14 '25 13:07 kruchininfl