fix: use replaceState for traces/roles redirects to preserve back-button history (#1883)

fix: use replaceState for traces/roles redirects to preserve back-button
history

The #/traces/<hash> and #/roles backward-compat redirects used
location.hash = ..., which pushes a new history entry instead of
replacing the current one. This trapped users navigating back from a
trace view: the intermediate #/traces/<hash> entry would immediately
re-redirect forward again on hashchange, so back button never reached
the packets view they came from.
This commit is contained in:
Jonathan Herlin authored and GitHub committed 2026-09-02 14:51:30 +02:00
1 parent f081f91b88
commit a46a6d55eb
1 file changed
+7 -3
+7 -3
View File
@@ -1039,16 +1039,20 @@ function navigate() {
closeNav();
// Backward-compat redirect: #/traces/<hash> → #/tools/trace/<hash> (issue #944).
// Uses replaceState (not location.hash =) so this redirect doesn't add its
// own history entry, otherwise the back button gets stuck bouncing off it.
if (location.hash.startsWith('#/traces/')) {
location.hash = location.hash.replace('#/traces/', '#/tools/trace/');
history.replaceState(null, '', location.hash.replace('#/traces/', '#/tools/trace/'));
navigate();
return;
}
// Backward-compat redirect: #/roles → #/analytics?tab=roles (issue #1085).
// The Roles page was folded into the Analytics tab strip; old links and
// bookmarks must keep working.
// bookmarks must keep working. Uses replaceState for the same reason as above.
if (location.hash === '#/roles' || location.hash.startsWith('#/roles?') || location.hash.startsWith('#/roles/')) {
location.hash = '#/analytics?tab=roles';
history.replaceState(null, '', '#/analytics?tab=roles');
navigate();
return;
}