diff --git a/src/App.tsx b/src/App.tsx index 66bdc58..f5960d9 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect, useCallback, useMemo, useRef, useTransition } from 'react'; +import React, { useState, useEffect, useCallback, useMemo, useRef } from 'react'; import { Truck, Warehouse, @@ -114,9 +114,17 @@ const TABS = [ ]; export default function App() { - const [activeTab, setActiveTabRaw] = useState<'overview' | 'department' | 'region' | 'customer'>('overview'); - const [, startTransition] = useTransition(); - const setActiveTab = useCallback((tab: typeof activeTab) => { startTransition(() => setActiveTabRaw(tab)); }, []); + const [activeTab, setActiveTab] = useState<'overview' | 'department' | 'region' | 'customer'>('overview'); + const [tabReady, setTabReady] = useState(true); + const prevTabRef = useRef(activeTab); + useEffect(() => { + if (prevTabRef.current !== activeTab) { + setTabReady(false); + prevTabRef.current = activeTab; + const id = requestAnimationFrame(() => { setTabReady(true); }); + return () => cancelAnimationFrame(id); + } + }, [activeTab]); const [theme, setTheme] = useState<'soft' | 'minimal' | 'vibrant'>('soft'); const [expandedModels, setExpandedModels] = useState>(new Set()); const [expandedAssetTypes, setExpandedAssetTypes] = useState>(new Set()); @@ -613,7 +621,13 @@ export default function App() { {/* Main Content Area */}
- {activeTab === 'overview' && ( + {!tabReady && ( +
+ +
+ )} + + {tabReady && activeTab === 'overview' && ( <> {/* Header Summary - Ultra Compact */}
@@ -1384,7 +1398,7 @@ export default function App() { )} - {activeTab === 'department' && ( + {tabReady && activeTab === 'department' && (
{/* Overall Total Summary (Compact) - Moved to Top */} @@ -1901,7 +1915,7 @@ export default function App() {
)} - {activeTab === 'region' && ( + {tabReady && activeTab === 'region' && (
{/* Region Distribution Chart */}
@@ -2175,7 +2189,7 @@ export default function App() {
)} - {activeTab === 'customer' && ( + {tabReady && activeTab === 'customer' && (
{/* Customer Region Distribution Chart */}