From 8a5b548a4a924ad9fb2012ebf646ed59b148c784 Mon Sep 17 00:00:00 2001 From: Barnabas Busa Date: Thu, 21 May 2026 11:22:03 +0200 Subject: [PATCH] slot: preserve active tab when navigating between slots Carry the URL hash forward on the prev/next chevrons so e.g. /slot/35#ptcVotes -> next chevron -> /slot/36#ptcVotes lands on the same tab. The chevron href is rewritten on page load, hashchange, and tab switches, so regular, middle, and cmd+click all preserve the tab. --- templates/slot/slot.html | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/templates/slot/slot.html b/templates/slot/slot.html index 8360d5101..a04364b89 100644 --- a/templates/slot/slot.html +++ b/templates/slot/slot.html @@ -3,13 +3,13 @@

{{- if not (eq .Slot 0) -}} - + {{- else -}} {{- end -}} Slot {{ .Slot }} {{- if gt .NextSlot 0 -}} - + {{- else -}} {{- end -}} @@ -455,8 +455,20 @@

Tracoor Traces
if (target.length) target.tab('show'); } + function syncSlotNavHashes() { + var hash = window.location.hash || ''; + $('.slot-nav-link').each(function() { + var base = this.getAttribute('data-slot-nav-base') || this.getAttribute('href'); + this.setAttribute('href', base + hash); + }); + } + activateTabByHash(); - window.addEventListener('hashchange', activateTabByHash); + syncSlotNavHashes(); + window.addEventListener('hashchange', function() { + activateTabByHash(); + syncSlotNavHashes(); + }); $('.nav-tabs a[data-bs-toggle="tab"]').on('shown.bs.tab', function(e) { var href = e.target.getAttribute('href') || ''; @@ -464,6 +476,7 @@
Tracoor Traces
var newHash = href === '#overview' ? '' : href; if (window.location.hash !== newHash) { window.history.replaceState(null, document.title, window.location.pathname + window.location.search + newHash); + syncSlotNavHashes(); } });