Closed mariia-mitiureva closed 4 months ago
It seems that ResizeObserver doesn't fire on non-active window in some browsers. Scheduled imperative scrolling waits for the resize events so timeout will happen.
As a workaround, you may be able to wait for the tab to be active with document.addEventListener("visibilitychange", callback)
or else, and then call imperative scroll. Or maybe we should implement similar logic inside virtua.
Maybe support of initial scroll position (https://github.com/inokawa/virtua/issues/415, https://github.com/inokawa/virtua/pull/422) could solve the issue? In the real project, where components are heavier than in storybook, this initial scroll to bottom sometimes is noticeable for user.
I understand. I guessed that if I had ability to set the initial scroll position without extra render cycle, maybe it wouldn't need to wait for resize events and the problem would go away.
A similar issue happens in safari if I switch pages back and forward by swiping. @inokawa do you have any idea why it can happen and how to fix it?
https://github.com/inokawa/virtua/assets/37265338/beb6fbfe-309d-4ac3-9967-09566fcca6a4
Thank you for the report! In the situation, window seems to be always active but scrollTo has timed out earlier than the initial resize. Maybe we should add a logic to wait for the initial resize and then trigger the scroll only on mount.
Fixed in 0.33.3
.
Describe the bug Scroll to bottom doesn't work correctly in inactive tab - video
To Reproduce
Expected behavior Scroll to bottom works correctly in inactive tab
Platform: