Closed pedroborges closed 2 months ago
This solution didn’t work. I cloned it from the master branch and used these changes in my project with npm link. While the issue persists on iOS browsers, I also started experiencing problems on browsers on my macOS device. @pedroborges
@AbdullahAgsar Yeah, I noticed last week that this fix caused some side effects on macOS browsers as well. Could you try the fix from #1992? I just tested it again and it resolves the navigation issues for me.
@pedroborges I tried the solution from #1992, but it didn’t work. I continue to experience issues with both forward and backward navigation in macOS browsers. Additionally, the issue in iOS browsers still persists.
@AbdullahAgsar Thanks for the feedback. Just to confirm, are you testing this in your project or one of the playgrounds?
Also, would you be able to provide a minimal reproducible repository? I’d love to investigate the issue further.
@pedroborges I tested it in my own project. I will try to create a blank project where the same issue occurs, and once completed, I will share the GitHub link with you.
Hello @pedroborges, I’ve been trying to solve the issue I’ve been facing for a long time using your solution. The issue wasn’t only present in iOS Chrome but also in iOS Edge. After making some adjustments along with your solution, I was able to come up with a fix for both browsers.
Initially, in the resolve block, I was using the following code:
const pages = import.meta.glob('./Pages/**/*.vue', { eager: true })
return pages[`./Pages/${name}.vue`]
But I had modified it to:
const pages = import.meta.glob('../../Pages/**/*.vue')
return pages[`../../Pages/${name}.vue`]()
After reverting this code back to its original state, most of the issues were resolved. However, I was still experiencing problems with the back navigation, like adding the same page to the history twice. To resolve these, I removed the Chrome check from the replaceState() function and adjusted it like this:
window.history.replaceState(cloneSerializable(page), '', page.url)
For the Edge browser, I created a variable called isEdgeIOS. With these changes, I was able to fix all the back navigation issues on both browsers.
On Chrome iOS, calling
this.storeScrollPositions
(which useshistory.replaceState
) right beforethis.setPage
in the routervisit
method caused timing issues withhistory.pushState
, leading to navigation problems.Wrapping
window.history.pushState
withsetTimeout
insiderouter.pushState
fixes the issue. UsingsetTimeout
defershistory.pushState
to the next event loop tick, preventing conflicts betweenhistory.replaceState
andhistory.pushState
. This change doesn’t introduce any side effects sincesetTimeout
with a delay of 0 just delays the execution without altering functionality.Fixes #1954.
Before
https://github.com/user-attachments/assets/f7ad94e9-46fb-4bec-9897-8d54758cd951
After
https://github.com/user-attachments/assets/2bb29406-ceb8-41ef-b4bd-8a5bff2f75f0
We could enhance this by detecting Chrome on iOS and only applying
setTimeout
there, but the current fix works universally without issues 🤷♂️