[fix](trx-frontend-http): fix map and statistics tabs requiring refresh to show data

Move template cloning into navigateToTab() so deferred <template>
content is materialized before any tab-specific initialization runs.
Previously the document-level template cloner fired after navigateToTab
due to event propagation order, causing initAprsMap() and
scheduleStatsRender() to target elements that did not yet exist. Also
defer statistics control wiring until the first render so event
listeners are attached after the template is cloned.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
2026-04-04 13:48:08 +02:00
parent 81427cd87b
commit bed49ce13b
3 changed files with 31 additions and 35 deletions
@@ -4444,7 +4444,14 @@ function navigateToTab(name, options = {}) {
document.querySelectorAll(".tab-bar .tab").forEach((t) => t.classList.remove("active"));
btn.classList.add("active");
document.querySelectorAll(".tab-panel").forEach((p) => p.style.display = "none");
document.getElementById(`tab-${name}`).style.display = "";
const panel = document.getElementById(`tab-${name}`);
panel.style.display = "";
// Clone deferred <template> content into the panel before any tab-specific init.
const tmpl = panel.querySelector("template");
if (tmpl) {
panel.appendChild(tmpl.content.cloneNode(true));
tmpl.remove();
}
if (updateHistory) {
updateTabHistory(name, replaceHistory);
}