virtual icon indicating copy to clipboard operation
virtual copied to clipboard

Vue: Scroll reset/jump when going up with dynamic height rows

Open exception-producer opened this issue 1 year ago • 5 comments

Describe the bug

When scrolling to the bottom of the list of dynamically sized rows and going back up, the scrolling view gets stuck and jumps back to the bottom around when the last row goes out of view. This does only seem to happen with the vue version though, but can already be reproduced with the documentation's example.

One can "escape" by scrolling up very quickly, but this should not happen, of course.

This sometimes also happens in random places of the list - however only when scrolling up. I've not been able to reproduce this consistently yet though. The root cause seems to be the same.

Your minimal, reproducible example

https://tanstack.com/virtual/v3/docs/framework/vue/examples/dynamic

Steps to reproduce

  1. Go to https://tanstack.com/virtual/v3/docs/framework/vue/examples/dynamic
  2. Scroll to the bottom
  3. Try scrolling back up

Expected behavior

That it scrolls as one would expect

How often does this bug happen?

Every time

Screenshots or Videos

https://github.com/user-attachments/assets/d7d64a3f-c6a9-42d5-bd7d-10cbd80eb396

Platform

every

tanstack-virtual version

3.13.0

TypeScript version

No response

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.

exception-producer avatar Feb 09 '25 22:02 exception-producer

Try overflow-anchor: none https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-anchor

It appears that Chrome has recently changed its behavior of automatically restoring the scroll when dom elements are removed or added. But the bug has always been there. Virtual scroll without "overflow-anchor" is undefined behavior.

This should be in the documentation.

Azq2 avatar Feb 24 '25 13:02 Azq2

@Azq2 thank u man!

melishev avatar Feb 28 '25 20:02 melishev

Try overflow-anchor: none developer.mozilla.org/en-US/docs/Web/CSS/overflow-anchor

It appears that Chrome has recently changed its behavior of automatically restoring the scroll when dom elements are removed or added. But the bug has always been there. Virtual scroll without "overflow-anchor" is undefined behavior.

This should be in the documentation.

@Azq2 you´re a hero!

marcomafessolli avatar Sep 15 '25 16:09 marcomafessolli

Try overflow-anchor: none https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-anchor

It appears that Chrome has recently changed its behavior of automatically restoring the scroll when dom elements are removed or added. But the bug has always been there. Virtual scroll without "overflow-anchor" is undefined behavior.

This should be in the documentation.

Interestingly, the same example on React does without this property and everything works fine.

melishev avatar Sep 20 '25 14:09 melishev

got the same issue with Firefox. The overflow-anchor: none; fix doesnt seem to be working there

craftycram avatar Nov 16 '25 21:11 craftycram