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

Preserving scroll position when clicking back button in browser/on mouse? #1459

Closed
ryggdunk opened this issue Feb 20, 2023 · 3 comments
Closed

Comments

@ryggdunk
Copy link

ryggdunk commented Feb 20, 2023

Versions:

  • @inertiajs/vue3 version: 1.0.0

Describe the problem:

I'm not sure if I'm misunderstanding how Inertia scroll management supposed to work.
If I have a list of posts (in main window, not scroll region), and I click a post (Inertia Link) and then go back using browser back button or mouse button, then there's a completely random chance that the scroll position will be restored or it will scroll to the top. Most of the time it scrolls back to top (this I don't want), but sometimes it preserve the scroll position, and I have no idea why.
I thought maybe something wrong in my project so I created a completely fresh installation with Laravel Jetstream / Inertia, but the issue remains.
I tried adding the preserveScroll to the link but that doesn't make any difference at all.

What am I doing wrong here?

EDIT:

I tried this in different browsers. I use Firefox as my main browser but when I tried this in Chrome it works much better. In Chrome scroll position is preserved like 95% of the time. In Firefox maybe 10%.

Steps to reproduce:

  • Install fresh version of Laravel Jetstream with Inertia
  • Make a long list of posts with links in a empty file, enough to create a scroll bar.
  • Try clicking on a link and then go back with the browser. Sometimes scroll position is preserved but most of the times it just scrolls back to top.
@benjivm
Copy link

benjivm commented Feb 23, 2023

I also use Firefox and have this issue, I rely on this polyfill to fix it.

@reinink
Copy link
Member

reinink commented Jul 28, 2023

Hey! Thanks so much for your interest in Inertia.js and for sharing this issue/suggestion.

In an attempt to get on top of the issues and pull requests on this project I am going through all the older issues and PRs and closing them, as there's a decent chance that they have since been resolved or are simply not relevant any longer. My hope is that with a "clean slate" me and the other project maintainers will be able to better keep on top of issues and PRs moving forward.

Of course there's a chance that this issue is still relevant, and if that's the case feel free to simply submit a new issue. The only thing I ask is that you please include a super minimal reproduction of the issue as a Git repo. This makes it much easier for us to reproduce things on our end and ultimately fix it.

Really not trying to be dismissive here, I just need to find a way to get this project back into a state that I am able to maintain it. Hope that makes sense! ❤️

@pedroborges
Copy link
Collaborator

pedroborges commented Sep 19, 2024

@ryggdunk please test if #1980 fixes this issue for you.

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

No branches or pull requests

4 participants