Users justin and rorycb reported a bug where the browser’s back button incorrectly returns to a previously visited topic instead of the topic list, observed on Safari/iPadOS beta, Firefox, Chrome, and macOS. eviltrout initially questioned reproducibility, but rorycb provided a semi-reliable reproduction method: clicking back before a topic fully loads causes the URL to rewrite to the last topic’s URL after the list loads. zogstrip asked if it was beta-specific, but rorycb confirmed it occurs on stable macOS and Chrome. eviltrout identified it as a loading-speed-related issue, and eviltrout fixed it by correcting a willTransition method that failed to return true, tracing the root cause to a recent commit unrelated to history API changes. The fix was committed at de6edf9.
There is likely some kind of link that our new history API fixes haven’t accounted for. If someone can help us isolate it we would be eternally grateful!
I have been playing with it for a bit here - I can’t give you exact steps, but I can trigger it 1 time in 5 (or more) by just picking a random topic, opening it, scrolling around, hitting back, then picking another random topic, opening it, scrolling around and hitting back again. Fairly often it will go back to the first topic, rather than the topic list.
Not a great repro case, but definitely hitting it a lot this way. Definitely no errors in the console when it happens.
edit: When it occurs, you can watch the URL when you hit back, it starts at meta.discourse.org/ and almost immediately after the list loads it re-writes the URL to the URL of the post you were just on
edit 2: I can actually trigger it almost constantly by clicking into this topic, scrolling up, then immediately clicking back (I have a back button mapped on my mouse - maybe that is why I can trigger it easily) - definitely looks like a timing issue for some return value.
edit 3: constant reproduction - click any topic, before it loads fully click back - URL re-writes after topic list loads to the URL of the post you just left
I was surprised to find this did not have to do with recent changes to the history, but was in fact caused by a new willTransition added in a recently merged commit.
I guess we should always remember to return true in willTransition methods!