Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

scrolling to middle of page after navigation #1317

Closed
jakecoffman opened this issue Jul 12, 2020 · 4 comments
Closed

scrolling to middle of page after navigation #1317

jakecoffman opened this issue Jul 12, 2020 · 4 comments

Comments

@jakecoffman
Copy link

jakecoffman commented Jul 12, 2020

Describe the bug

Scroll down on a long page, click a link to another long page. Once the new page loads you will be part of the way down the page already.

Pinning to sapper to 0.27.7 seems to fix it.

Logs

No errors.

To Reproduce

Source is here https://github.com/jakecoffman/stldevs-sapper

Expected behavior

I should be at the top of the next page, not the middle/bottom.

Stacktraces

No stacktraces.

Information about your Sapper Installation:

  • Edge 83.0.478.61
  • Windows
  • Local, VPS
  • Sapper version 0.27.16
  • Svelte version 3.24.0
  • not exported
  • Rollup

Severity

Workaround pinning to previous version is acceptable, no rush.

Additional context

Svelte and Sapper are awesome!

@jakecoffman
Copy link
Author

Actually pinning to an old version doesn't fix it, seems to happen randomly after navigating back and forth.

@habibrosyad
Copy link
Contributor

habibrosyad commented Jul 13, 2020

Could confirm this. If you scroll down and click on the link fast enough (before the prefetch complete/kick in) then you will get the correct behaviour. However, once you open a page then you navigate back and click on the same link again (resources already cached for the page), then the scroll will not reset to the top of the page (unless you remove the cache). But, I'm not sure whether this is a problem in Sapper or maybe Svelte...

@jakecoffman
Copy link
Author

I removed prefetch and it fixed it, thanks @habibrosyad.

@jakecoffman
Copy link
Author

Turns out removing prefetch didn't fix it all the time.

I finally tracked down the issue. It was due to height: 100%; on html, body in my global.css.

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

No branches or pull requests

2 participants