Turbo history navigation may behave oddly in Safari
See original GitHub issueSome context in https://github.com/WICG/interventions/issues/21#issuecomment-224017911
Looks like Safari has an heuristic where if a script runs history.pushState
after 500ms of the last user interaction, Safari will flag that history state as spammy and it will skip it when clicking the back button.
Here’s a quick repro, using Charles Proxy to throttle the network, making requests take more than 500ms:
The only code change I made was
--- a/src/tests/fixtures/one.html
+++ b/src/tests/fixtures/one.html
@@ -9,6 +9,7 @@
</head>
<body>
<h1>One</h1>
+ <p><a id="same-origin-link" href="/src/tests/fixtures/two.html">Same-origin link</a></p>
<!--styles ensure that the element will be scrolled to top when navigated to via an anchored link -->
<a name="named-anchor"></a>
Notes
- Running
history.back()
works fine, so creating a test-case is hard sincepage.goBack()
uses the history API instead of actually clicking the back button - Maybe this is solvable by pushing the state earlier, but I remember we had issues with that in the past
- This behavior only happens in Safari. I’m using version 16.0, not sure if this bug is present in other versions
Issue Analytics
- State:
- Created 9 months ago
- Reactions:2
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Annoying user experience on back navigation due to dummy ...
Typically, the History get stuffed with multiple dummy entries that fast-forward ... Turbo history navigation may behave oddly in Safari hotwired/turbo#810.
Read more >Keep your browsing history private in Safari and Maps
Keep your browsing history private in Safari and Maps. Reviewing and clearing search history and caches for browsers and other apps may be...
Read more >Safari browser is acting weird! How to fi… - Apple Community
Safari /Preferences/Advanced - enable the Develop menu, then go there and Empty Caches. Quit/reopen Safari and test. Then try Safari/History/Show ...
Read more >Customize your Safari settings on iPad - Apple Support
In the Safari app , you can customize your start page, change the text size on websites, and change display and privacy settings....
Read more >Keyboard shortcuts and gestures in Safari on Mac
Note: Keyboard shortcuts in apps may vary depending on the language and ... Tab also highlights buttons and other controls if Keyboard Navigation...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m pretty sure the culprit is https://github.com/hotwired/turbo/pull/601 It changes Turbo to only
pushState
when the fetch request is done, and if the fetch takes too long we see the bug here.Unfortunately, that PR is solving another scroll bug, so the fix here isn’t simply reverting it 😕
Thanks for the extra context @manuelpuyol. I wasn’t aware of it. I thought identifying the issue was the first step, but looks like we’re already there. If there’s anything I can do to help, please let me know.