From b68a53eb53a699817b501b07d1d12491154dce82 Mon Sep 17 00:00:00 2001 From: James Smith Date: Thu, 21 May 2026 22:07:41 +0100 Subject: [PATCH] fix: prevent full page reload when clicking Main Dashboard button Intercept .nav-dashboard-btn clicks to perform SPA-style navigation instead of a full page reload. After switchMode() updates the URL to /?mode= via pushState, clicking href="/" previously caused a round- trip reload. Now the click handler stops active scans, destroys the current mode, shows the welcome overlay, and pushes '/' onto history. Also update popstate to restore the welcome page when navigating back to '/' with no mode param. Co-Authored-By: Claude Sonnet 4.6 --- templates/index.html | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/templates/index.html b/templates/index.html index 6eca2f8..cdc9a9d 100644 --- a/templates/index.html +++ b/templates/index.html @@ -4609,6 +4609,31 @@ }); } + if (!window._dashboardHomeBtnBound) { + window._dashboardHomeBtnBound = true; + document.addEventListener('click', (event) => { + if (event.defaultPrevented || event.button !== 0) return; + if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return; + const link = event.target && event.target.closest + ? event.target.closest('.nav-dashboard-btn') + : null; + if (!link) return; + try { + const href = new URL(link.href, window.location.href); + if (href.origin !== window.location.origin || href.pathname !== '/') return; + } catch (_) { return; } + event.preventDefault(); + stopActiveLocalScansForNavigation(); + destroyCurrentMode(); + const welcome = document.getElementById('welcomePage'); + if (welcome) { + welcome.classList.remove('fade-out'); + welcome.style.display = ''; + } + window.history.pushState({}, '', '/'); + }); + } + function postStopRequest(url, timeoutMs = LOCAL_STOP_TIMEOUT_MS) { const controller = (typeof AbortController !== 'undefined') ? new AbortController() : null; const timeoutId = controller ? setTimeout(() => controller.abort(), timeoutMs) : null; @@ -5157,6 +5182,13 @@ const mode = getModeFromQuery(); if (mode && mode !== currentMode) { switchMode(mode, { updateUrl: false }); + } else if (!mode) { + destroyCurrentMode(); + const welcome = document.getElementById('welcomePage'); + if (welcome) { + welcome.classList.remove('fade-out'); + welcome.style.display = ''; + } } });