Scroll position doesn't stay at the bottom when viewport height changes
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
- Open Storybook -> Advanced -> Chat
- Comment out new messages generation
- 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
Hi, this behavior is currently expected one. What do you need it for?
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?
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.
Hi @inokawa! Do you have any estimates for this issue?
It's planned but not right away.
hi @inokawa do you a rough idea on how you would implement it? I would like to help with this feature
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 so this means that users need to have an ability to scroll to bottom synchronously. Now it's not possible
@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?
Both may need onResize like prop but not sure.