Merge Request tabs & URL interaction improvement
What does this MR do and why?
For #371066 (closed).
In some circumstances, the URL won't change when you move among tabs on the MR page.
Specifically: sometimes the diffs tab doesn't have a state entry pushed into history management (either because it's the first tab visited OR because clicking on a line code actually triggers a popstate
- not sure why this was). Without this history state entry, the URL is not updated because a state entry is required to do comparisons.
To fix that, this MR introduces what is essentially two changes:
- Always set the "current action" (e.g. which tab, and it's associated data) when showing a tab
- Always use the
tabShown
code to change tabs, even when it's not via a click (e.g. when clicking the back/fwd browsers buttons via history navigation)
The latter fix there is for existing code which was giving special code paths to the back button (popstate
).
I add a simple utility to get which action it should be from the URL, and use that as soon as popstate
occurs (the URL will already update by the time popstate
happens).
Once we have the action, the back button can act just like a tab click, instead of having special handling code.
We essentially don't need the state value from the history API at all.
Screenshots or screen recordings
This is all browser URL bar stuff, so there's not really a great way to show what's happening.
How to set up and validate locally
See the notes in #371066 (closed).
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.