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 issue when navigating between pages #2760

Closed
gavinr opened this issue Nov 9, 2021 · 2 comments · Fixed by #2761
Closed

Scroll issue when navigating between pages #2760

gavinr opened this issue Nov 9, 2021 · 2 comments · Fixed by #2761
Labels
bug Something isn't working router

Comments

@gavinr
Copy link

gavinr commented Nov 9, 2021

Describe the bug

When scrolling down on a page then clicking a link, the next page is scrolled down when it should not be.

Reproduction

  1. Go to https://gavinr.github.io/sveltekit-scroll-issue/
  2. Scroll down 75% on the page, click link ~400
  3. Next page loads.
    • Expected: page loads with scroll at top of page
    • Actual: page loads scrolled down to bottom of page.

Logs

None

System Info

System:
    OS: Have tested this on Windows 10 and Linux (Mint)
  Binaries:
    Node: 14.18.1 - /usr/bin/node
    npm: 8.1.1 - /usr/bin/npm
  Browsers:
    Have tested on chrome and Firefox (latest) - happens on both
  npmPackages:
    @sveltejs/adapter-static: ^1.0.0-next.21 => 1.0.0-next.21 
    @sveltejs/kit: next => 1.0.0-next.195 
    svelte: ^3.42.6 => 3.44.1

Severity

serious

Additional Information

  1. See code at https://github.com/gavinr/sveltekit-scroll-issue
  2. It looks like the issue started at version next.193. For example, if you clone the above repository and run npm install @sveltejs/kit@1.0.0-next.192 it will work correctly, but if you run npm install @sveltejs/kit@1.0.0-next.193 it will be broken.
  3. This is possibly the same issue as Incorrect scrolling when navigating between pages #2720 from @NewNik - I think that one was closed in error as you can see this clear replication case the scroll issues are still happening.
@bluwy bluwy added bug Something isn't working router labels Nov 9, 2021
@f-elix
Copy link
Contributor

f-elix commented Nov 12, 2021

I just tested this fix on version next.196 in a production project (in a dev environment) and I am still getting scrolling issues when navigating.

It's very hard to pin down a particular condition because it happens inconsistently. Sometimes the same navigation that worked previously will stop working and vice-versa. I know that I'm not controlling the scroll in any of the components and the body has no margin.

I noticed it happens more often when I scroll past the first half of the page before navigating to another page.

I reverted back to next.192 in the meantime, just wanted to let you know that the issue is still present.

@gavinr
Copy link
Author

gavinr commented Nov 13, 2021

@f-elix thank you - I have updated my demo case to vnext.196 and also am having issues. Since I cannot re-open this issue, I will open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working router
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants