Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

Page scroll position #6

Closed
andrewmclagan opened this issue Jun 6, 2018 · 3 comments
Closed

Page scroll position #6

andrewmclagan opened this issue Jun 6, 2018 · 3 comments

Comments

@andrewmclagan
Copy link

What happens

When clicking the back button on a browser the page y . scroll position is set to the top of the page. This is a critical issue for many use cases as on long scrolling results pages the user would have to re-find their position in the page.

Expected

The scroll position is remembered and the page transitions back to the previous position. As per normal NextJs behaviour.

@nwalters512
Copy link
Member

This library shouldn't do anything with scrolling, with the exception of optionally disabling scrolling during transitions with the monkeyPatchScrolling prop.

@EyMaddis
Copy link

EyMaddis commented May 28, 2019

It is possible to adapt the ScrollMemory component from react-router-scroll-memory for Next.js

@nwalters512
Copy link
Member

This appears to be related to vercel/next.js#1309. TL;DR this is all handled by the browser, and it appears that simply adding transitions makes changing pages take long enough that the browser gives up on trying to restore the previous scroll position. I think the only reason that maintaining scroll position works for some Next.js pages is because they aren't loading data, and thus the page change completes quick enough that the browser can do its usual scroll position restoration.

Given that this is a problem with Next.js itself and this library only makes the problem apparent (it isn't actually the root cause), I'm going to close out this issue. As @arunoda suggested in the other issue, this should be implemented in another userspace package. Solving this problem is beyond the scope of next-page-transitions.

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

3 participants