TanStack / TanStack/virtual

Dynamic item sizes are not recalculated after reordering

Open
#1,084 2 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
7.1k
Forks
466
Avg merge
2d 31m
Merged PRs (30d)
13

Description

Describe the bug

In a virtualized list using @tanstack/vue-virtual, reordering items with dynamic or varying sizes (e.g., different heights) does not trigger a recalculation of their cached measurements. As a result, the items retain their initial rendered dimensions post-reorder, leading to visual artifacts such as:

  • Larger items being clipped or overflowing within the constrained space originally allocated to smaller items.
  • Smaller items leaving empty gaps due to mismatched container sizes.
Your minimal, reproducible example

https://stackblitz.com/edit/tanstack-virtual-xbv5kvkh?file=src%2FApp.vue

Steps to reproduce
  1. Click the Swap button
  2. Look at the list's second and third items
Expected behavior

After reordering, the virtualizer should re-measure and update the sizes for affected items

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform
  • Windows - Chrome - v.142.0.7444.61
tanstack-virtual version

v3.13.12

TypeScript version

v5.4.5

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked StackBlitz reproduction and inspect the @tanstack/vue-virtual measurement and cache handling used when the Swap button reorders items. Verify the second and third items with varying heights, then run the reproduction again after the change. Done means affected items are re-measured after reordering without clipping or empty gaps.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.