-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Binding scrollY to svelte:window
causes implicit scrolling to the top of the page
#11623
Comments
This is already fixed in the latest version of 5.0-next, make sure to update the version. |
@dummdidumm Can you tell me if this change will be reflected in Svelte 4? If not, it might be worth mentioning it in #11400. Thanks! |
Does the bug even exist in Svelte 4? |
@dummdidumm https://stackblitz.com/edit/vitejs-vite-f8dfha?file=src%2Froutes%2F%2Bpage.svelte - no, you're right, there is no bug in Svelte 4. |
@dummdidumm But I found another related bug:
|
- we were scrolling to the given value, which we shouldn't for accessibility reasons (Svelte 4 didn't do it either) - we need to notify of the value 0 if there's no scroll (#11623 (comment))
- we were scrolling to the given value, which we shouldn't for accessibility reasons (Svelte 4 didn't do it either) - we need to notify of the value 0 if there's no scroll (#11623 (comment))
@dummdidumm I found the issue again in my app. The example this time is a little more complicated:
Any deletion fixes the issue (e.g. if you remove Svelte 5.0.0-next.135 🟢 - when refreshing, the page scrolls smoothly from the beginning to the position where it was before the refresh. iShot_2024-05-17_17.11.02.mp4Svelte 5.0.0-next.136 🔴 - when refreshing, the page instantly scrolls to the beginning and stays in that position. iShot_2024-05-17_17.13.59.mp4 |
- the previous assumption was wrong: browser don't fire a scroll event initially when the scroll isn't smooth - the previous logic wasn't using the "is scrolling now" logic which meant the render effect fired immediately after, causing smooth scrolling to start too late to be overridden adjusted the comment and reused the scroll handler function to guard against the race condition fixes #11623
…11802) - the previous assumption was wrong: browser don't fire a scroll event initially when the scroll isn't smooth - the previous logic wasn't using the "is scrolling now" logic which meant the render effect fired immediately after, causing smooth scrolling to start too late to be overridden adjusted the comment and reused the scroll handler function to guard against the race condition fixes #11623
Describe the bug
In the example from the video, I scroll and then refresh the page. In the case where
scrollY
is bound tosvelte:window
, the page scrolls to the beginning after refresh. If no binding is done, the page does not scroll.Most likely the same thing happens with
scrollX
.iShot_2024-05-15_00.44.03.mp4
Reproduction
https://stackblitz.com/edit/vitejs-vite-8xmzpm?file=src%2Froutes%2F%2Bpage.svelte
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: