Skip to content

getTotalSize reports a negative value for empty list when scrollMargin is set #827

Closed

Description

@afarnsworth-valve

Describe the bug

When a virtualizer is configured with scrollMargin, getTotalSize() will return negative values when count is 0.

Your minimal, reproducible example

https://codesandbox.io/p/devbox/virtualizer-gettotalsize-scrollmargin-issue-f3jl4p

Steps to reproduce

On the code pen, click the "0 rows" button to observe the negative value from getTotalSize(). Switching between valid values, you can see that the scrollbar updates. The element remains the last height returned from getTotalSize() because the negative height value is invalid.

Expected behavior

When there are elements, the scrollMargin is included in the measurements and getTotalSize subtracts it back out. When there are no elements, subtracting it out results in a negative value.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

Chrome Windows

tanstack-virtual version

3.10.6

TypeScript version

5.5.3

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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