fix: prevent blank screen for new users migrating to widget dashboard
Fixed critical initialization timing bug where new users saw a blank screen
with error "Tab not found: main" when migrating from v1.x to v2.0.
Root Cause:
- dashboardManager.init() created a premature fallback "main" tab before
loading the default layout
- TabManager was initialized with activeTabId='main'
- loadLayout() then replaced tabs with proper IDs ('tab-status', etc.)
- TabManager still referenced the non-existent 'main' tab
- Result: blank screen
Changes:
1. Removed premature fallback tab creation (lines 189-198)
- Default layout is always set via setDefaultLayout() before init()
- No need to create "main" tab before layout loads
2. Added safety check after loadLayout() completes (line 1506-1520)
- If no tabs exist after loading, create emergency fallback
- Uses correct tab ID 'tab-status' instead of 'main'
- Updates TabManager's activeTab to match
Flow now:
- init() creates TabManager with empty tabs
- loadLayout() populates tabs from default or saved layout
- Safety check ensures at least one tab exists
- TabManager references only valid tab IDs
Fixes blank screen bug for users migrating from v1.x to v2.0.
This commit is contained in:
@@ -185,18 +185,8 @@ export class DashboardManager {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Initialize Tab Manager with dashboard data structure
|
// Initialize Tab Manager with dashboard data structure
|
||||||
// Create default tab if no tabs exist
|
// Note: Tabs will be populated by loadLayout() which runs after init()
|
||||||
if (this.dashboard.tabs.length === 0) {
|
// Default layout is set via setDefaultLayout() before init() is called
|
||||||
this.dashboard.tabs.push({
|
|
||||||
id: 'main',
|
|
||||||
name: 'Main',
|
|
||||||
icon: 'fa-solid fa-house',
|
|
||||||
order: 0,
|
|
||||||
widgets: []
|
|
||||||
});
|
|
||||||
this.dashboard.defaultTab = 'main';
|
|
||||||
}
|
|
||||||
|
|
||||||
this.tabManager = new TabManager(this.dashboard);
|
this.tabManager = new TabManager(this.dashboard);
|
||||||
|
|
||||||
// Set current tab to active tab from TabManager
|
// Set current tab to active tab from TabManager
|
||||||
@@ -1512,6 +1502,22 @@ export class DashboardManager {
|
|||||||
this.applyDashboardConfig(this.defaultLayout);
|
this.applyDashboardConfig(this.defaultLayout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Safety check: If still no tabs after loading, create emergency fallback
|
||||||
|
// This should never happen if setDefaultLayout() was called properly
|
||||||
|
if (this.dashboard.tabs.length === 0) {
|
||||||
|
console.warn('[DashboardManager] No tabs loaded, creating emergency fallback');
|
||||||
|
this.dashboard.tabs.push({
|
||||||
|
id: 'tab-status',
|
||||||
|
name: 'Status',
|
||||||
|
icon: 'fa-solid fa-user',
|
||||||
|
order: 0,
|
||||||
|
widgets: []
|
||||||
|
});
|
||||||
|
this.dashboard.defaultTab = 'tab-status';
|
||||||
|
// Update TabManager's active tab
|
||||||
|
this.tabManager.setActiveTab('tab-status');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user