Skip to content

React: Conditionally rendering causes scroll element to scroll to top #1038

@mjchang

Description

@mjchang

Describe the bug

When a 2nd conditionally rendered virtual list is rendered, the page automatically scrolls to the top

Your minimal, reproducible example

https://codesandbox.io/p/devbox/cranky-fermat-vzkmd3

Steps to reproduce

Scroll to bottom and click the Render More button. Once clicked the 2nd virtualized list will render and the page will scroll to the top

Expected behavior

When the 2nd virtualized list is rendered, the page should not scroll to the top.

How often does this bug happen?

Every time

Screenshots or Videos

Screen.Recording.2025-07-22.at.5.37.23.PM.mov

Platform

  • OS: macOS
  • Browser: Chrome 137

tanstack-virtual version

3.13.12

TypeScript version

5.8.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.

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