virtua icon indicating copy to clipboard operation
virtua copied to clipboard

Scroll position doesn't stay at the bottom when viewport height changes

Open mariia-mitiureva opened this issue 2 years ago • 10 comments

Describe the bug

If scroll reaches the very bottom position, it stays at the bottom when items are resized. It actually works and looks like expected behavior to me. However, when viewport size changes, it doesn't work like this (see attached video) https://github.com/inokawa/virtua/assets/37265338/dcd04cd9-4682-4d12-af6d-3e9dd75f185e

To Reproduce

  1. Open Storybook -> Advanced -> Chat
  2. Comment out new messages generation
  3. Change browser window height

Expected behavior I think, scroll position should stay at the bottom on any size changes

Platform:

  • Browser: I checked it in Chrome and Safari
  • Version of this package: 0.18.0
  • Version of framework: react 18.2.0

mariia-mitiureva avatar Dec 28 '23 18:12 mariia-mitiureva

Hi, this behavior is currently expected one. What do you need it for?

inokawa avatar Dec 28 '23 21:12 inokawa

I use it for a chat app. It seemed logical to me, that scroll position stays at the bottom. When a user opens a chat and then resizes the window, I would be weird not to see the very beginning of the conversation.

Do you think this behavior might be wrong in some cases? Could it stay at the bottom for reverse: true only?

mariia-mitiureva avatar Dec 28 '23 22:12 mariia-mitiureva

Thanks. It seems worth implementing. I think it should be for reverse: true because it is different from native behavior of scrollable element and it is required only for chat like reverse scrolling usage.

inokawa avatar Dec 28 '23 23:12 inokawa

Hi @inokawa! Do you have any estimates for this issue?

mariia-mitiureva avatar Jan 16 '24 14:01 mariia-mitiureva

It's planned but not right away.

inokawa avatar Jan 16 '24 14:01 inokawa

hi @inokawa do you a rough idea on how you would implement it? I would like to help with this feature

LookRain avatar Apr 18 '24 10:04 LookRain

This library doesn't know the current distance to the bottom end. It's necessary restriction to support #315.

So I would add onResize like prop and allow users to implement their own "scroll to bottom if at bottom" logic if I try to do. https://github.com/inokawa/virtua/blob/a567e46c3c373cf0c7fe349b374316e00e160b5b/stories/react/basics/VList.stories.tsx#L600-L607

inokawa avatar Apr 18 '24 15:04 inokawa

@inokawa so this means that users need to have an ability to scroll to bottom synchronously. Now it's not possible

mariia-mitiureva avatar Jun 21 '24 11:06 mariia-mitiureva

@inokawa hi, does what you said above apply to https://github.com/inokawa/virtua/issues/408 as well? I mean "This library doesn't know the current distance to the bottom end. It's necessary restriction to support https://github.com/inokawa/virtua/issues/315."

And do you have any idea how to allow users to scroll to bottom synchronously?

mariia-mitiureva avatar Jul 31 '24 14:07 mariia-mitiureva

Both may need onResize like prop but not sure.

inokawa avatar Aug 02 '24 04:08 inokawa