From 14687e7ba68619734a825759fb23cce008212198 Mon Sep 17 00:00:00 2001 From: Shawn Date: Thu, 21 May 2026 07:45:16 -0400 Subject: [PATCH] Fix Nav tab infinite recursion (pre-UX-sweep bug) The reverted code had two bugs in the tab switching logic: 1. closeNavigate() called switchTab() -> infinite recursion since switchTab() calls closeNavigate() when leaving tabNavigate 2. currentTab was updated AFTER closeNavigate(), so the recursive call hit the same condition over and over Fix: move currentTab assignment before cleanup, use a wasNavigating flag to track the old tab state, and make closeNavigate() only reset nav UI (caller handles tab transition). --- static/index.html | 21 +++++++++++++++------ tests/test_map_api.db-shm | Bin 0 -> 32768 bytes tests/test_map_api.db-wal | 0 3 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 tests/test_map_api.db-shm create mode 100644 tests/test_map_api.db-wal diff --git a/static/index.html b/static/index.html index 5699739..dcf4bf5 100644 --- a/static/index.html +++ b/static/index.html @@ -2339,15 +2339,19 @@ // TAB SWITCHING // ========================================================================= function switchTab(tabId) { + const wasNavigating = AppState.currentTab === 'tabNavigate'; // Track previous tab for back navigation - if (AppState.currentTab !== tabId && AppState.currentTab !== 'tabNavigate') { + if (AppState.currentTab !== tabId && !wasNavigating) { AppState._prevTab = AppState.currentTab; } - // Cleanup nav page when leaving - if (AppState.currentTab === 'tabNavigate' && tabId !== 'tabNavigate') { + // Update current tab BEFORE cleanup to prevent recursion + // when closeNavigate() calls switchTab() + AppState.currentTab = tabId; + // Cleanup nav page when leaving (closeNavigate only resets nav state, + // it does NOT switch panels — we must NOT return early here) + if (wasNavigating && tabId !== 'tabNavigate') { closeNavigate(); } - AppState.currentTab = tabId; // Update tab panels document.querySelectorAll('.tab-panel').forEach(p => p.classList.remove('active')); @@ -3681,8 +3685,13 @@ function closeNavigate() { if (navMap) { navMap.remove(); navMap = null; } AppState._navData = null; - // Go back to previous tab or asset list - switchTab(AppState._prevTab || 'tabAssets'); + // Reset navigate tab UI — does NOT switch tabs, caller handles that + const infoCard = document.getElementById('navInfoCard'); + if (infoCard) infoCard.style.display = 'none'; + const directionsCard = document.getElementById('navDirectionsCard'); + if (directionsCard) directionsCard.style.display = 'none'; + const gmapsLink = document.getElementById('navGoogleMapsLink'); + if (gmapsLink) gmapsLink.style.display = 'none'; } function clearRouteLine() { diff --git a/tests/test_map_api.db-shm b/tests/test_map_api.db-shm new file mode 100644 index 0000000000000000000000000000000000000000..fe9ac2845eca6fe6da8a63cd096d9cf9e24ece10 GIT binary patch literal 32768 zcmeIuAr62r3