[fix] reset scroll when navigated from scrolled page#2735
Conversation
🦋 Changeset detectedLatest commit: a27ed45 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Could this result in a behavior of jumping to the top of the page and the down to the final scroll position? |
This would technically happen from the code flow, but it happens between an |
benmccann
left a comment
There was a problem hiding this comment.
thanks for updating these tests!
Fixes #2733 and maybe #2664
Move the scroll to top logic before the new route mounts so that we can properly compare the
pageYOffset === 0. This works because scroll position is preserved between route changes by default.I also updated our
isVisble()tests tois_intersecting_viewport(), sinceisVisblechecks for visibility anywhere in the document.is_intersecting_viewportmakes sure they are in the viewport.Nonetheless, @mquandalle and @mikenikles I'd appreciate if y'all can try to see if this branch fixes your issue as well.
Before submitting the PR, please make sure you do the following
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpx changesetand following the prompts. All changesets should bepatchuntil SvelteKit 1.0