Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scroll to bottom doesn't work correctly in inactive tab #450

Open
mariia-mitiureva opened this issue May 16, 2024 · 4 comments
Open

Scroll to bottom doesn't work correctly in inactive tab #450

mariia-mitiureva opened this issue May 16, 2024 · 4 comments
Assignees

Comments

@mariia-mitiureva
Copy link
Contributor

mariia-mitiureva commented May 16, 2024

Describe the bug
Scroll to bottom doesn't work correctly in inactive tab - video

To Reproduce

  1. Bookmark this storybook page https://inokawa.github.io/virtua/?path=/story/advanced-chat--default
  2. Open it in a new tab (tab should be inactive while page is loading)
  3. Go to that tab
    Result: list is not scrolled to the bottom

Expected behavior
Scroll to bottom works correctly in inactive tab

Platform:

  • Browser: reproduced in Chrome and Edge, not reproduced in Safari
  • Version of this package: 0.31.0
@inokawa
Copy link
Owner

inokawa commented May 17, 2024

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.

@mariia-mitiureva
Copy link
Contributor Author

Maybe support of initial scroll position (#415, #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.

@inokawa inokawa self-assigned this May 18, 2024
@inokawa
Copy link
Owner

inokawa commented May 18, 2024

#415 will not solve this issue, because #415 is just an unimplemented feature but this issue is a browser problem.

@mariia-mitiureva
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants