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).
This commit is contained in:
+15
-6
@@ -2339,15 +2339,19 @@
|
|||||||
// TAB SWITCHING
|
// TAB SWITCHING
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
function switchTab(tabId) {
|
function switchTab(tabId) {
|
||||||
|
const wasNavigating = AppState.currentTab === 'tabNavigate';
|
||||||
// Track previous tab for back navigation
|
// Track previous tab for back navigation
|
||||||
if (AppState.currentTab !== tabId && AppState.currentTab !== 'tabNavigate') {
|
if (AppState.currentTab !== tabId && !wasNavigating) {
|
||||||
AppState._prevTab = AppState.currentTab;
|
AppState._prevTab = AppState.currentTab;
|
||||||
}
|
}
|
||||||
// Cleanup nav page when leaving
|
// Update current tab BEFORE cleanup to prevent recursion
|
||||||
if (AppState.currentTab === 'tabNavigate' && tabId !== 'tabNavigate') {
|
// 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();
|
closeNavigate();
|
||||||
}
|
}
|
||||||
AppState.currentTab = tabId;
|
|
||||||
|
|
||||||
// Update tab panels
|
// Update tab panels
|
||||||
document.querySelectorAll('.tab-panel').forEach(p => p.classList.remove('active'));
|
document.querySelectorAll('.tab-panel').forEach(p => p.classList.remove('active'));
|
||||||
@@ -3681,8 +3685,13 @@
|
|||||||
function closeNavigate() {
|
function closeNavigate() {
|
||||||
if (navMap) { navMap.remove(); navMap = null; }
|
if (navMap) { navMap.remove(); navMap = null; }
|
||||||
AppState._navData = null;
|
AppState._navData = null;
|
||||||
// Go back to previous tab or asset list
|
// Reset navigate tab UI — does NOT switch tabs, caller handles that
|
||||||
switchTab(AppState._prevTab || 'tabAssets');
|
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() {
|
function clearRouteLine() {
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user