question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Turbo history navigation may behave oddly in Safari

See original GitHub issue

Some 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:

https://user-images.githubusercontent.com/11280312/205973098-7a04d454-e178-4a89-9e1d-d060593a6ba1.mov

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 since page.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:open
  • Created 9 months ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
manuelpuyolcommented, Dec 12, 2022

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 😕

0reactions
gingerlimecommented, Dec 12, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found