mirror of
https://github.com/Kpa-clawbot/meshcore-analyzer.git
synced 2026-10-23 11:12:32 +00:00
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:
1 parent
f081f91b88
commit
a46a6d55eb
1 file changed
+7
-3
+7
-3
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user