Next.js link prefetch causes scrolling to top
Unanswered
Sun bear posted this in #help-forum
Sun bearOP
Strange issue. I have a page to view a blog post, that is fetched from the cms. At the very bottom of the page I have a footer section for the blog post with its categories, tags, and related posts. Those are all link components to the respective page.
When scrolling down the blog post, at some point the scroll just jumps back to the top of the page. Managed to figure out through DevTools it happens the moment any of those link components come into view and get prefetched.
Code: https://gist.github.com/Ma-Kas/e30a5d0aeae51ee4c2a3055dd8e81182
Not really sure where to even start, as prefetching links shouldn't cause scrolling, and doesn't on any other page. The other strange thing, it doesn't happen locally, only after deploying to Vercel, so a bit difficult to debug.
When scrolling down the blog post, at some point the scroll just jumps back to the top of the page. Managed to figure out through DevTools it happens the moment any of those link components come into view and get prefetched.
Code: https://gist.github.com/Ma-Kas/e30a5d0aeae51ee4c2a3055dd8e81182
Not really sure where to even start, as prefetching links shouldn't cause scrolling, and doesn't on any other page. The other strange thing, it doesn't happen locally, only after deploying to Vercel, so a bit difficult to debug.