Skip to content

Lane assignments should respect measured sizes, not just estimates #1114

@2wheeh

Description

@2wheeh

Describe the bug

#1080 added caching for initial lanes assignment, which introduced a breaking change in functionality where dynamic lane assignments is needed.

As I understand it, estimateSize is meant to provide a rough estimate when the actual size cannot be known beforehand.

While caching lane assignments from estimateSize is good for visual stability by limiting shifts into height changes, It makes dynamic lane assignment impossible, which is core requirement for masonry style layouts. Consumer may need more complex tweaks for achieving this.

If we don't want to change the default behaviour, adding an option to defer lane caching until the first measurement would be very helpful (e.g., deferLaneAssignment.)

Lanes assinged based on estimateSize since v3.13.13 - Left to Right, ignoring measured sizes:

Image

Your minimal, reproducible example

https://stackblitz.com/~/github.com/2wheeh/virtual-lane-assign-repro

Steps to reproduce

  1. Go to repro stackblitz
  2. You can see the issue
  3. Run pnpm before and restart the dev server (pnpm dev)
  4. You can see how it used to be

Expected behavior

Lanes assigned based on actual measured sizes:

Image

How often does this bug happen?

None

Screenshots or Videos

No response

Platform

macOS (but the issue is platform agonistic)

tanstack-virtual version

v3.13.18 (after v.3.13.12)

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions