@@ -57,11 +57,29 @@ const SidebarContainer: React.FC<SidebarContainerProps> = ({
5757 : "300px" ;
5858 console . log ( "[SidebarContainer] width calc:" , { isCollapsed, customWidth, wide, computedWidth : width } ) ;
5959
60+ // Track previous width to detect tab switches vs resize drags
61+ // Tab switches: large width jumps (e.g., 400→976) - no animation wanted
62+ // Resize drags: small incremental changes - smooth animation wanted
63+ const prevWidthRef = React . useRef < string > ( width ) ;
64+ const widthDelta = Math . abs (
65+ parseInt ( width ) - parseInt ( prevWidthRef . current )
66+ ) ;
67+ // Consider it a "tab switch" if width changes by more than 50px in one render
68+ const isTabSwitch = ! isNaN ( widthDelta ) && widthDelta > 50 ;
69+
70+ React . useEffect ( ( ) => {
71+ prevWidthRef . current = width ;
72+ } , [ width ] ) ;
73+
74+ // Only animate during resize (small incremental changes), not tab switches
75+ const shouldAnimate = ! isResizing && ! isTabSwitch ;
76+ console . log ( "[SidebarContainer] animation:" , { width, prevWidth : prevWidthRef . current , widthDelta, isTabSwitch, shouldAnimate } ) ;
77+
6078 return (
6179 < div
6280 className = { cn (
6381 "bg-sidebar border-l border-border-light flex flex-col overflow-hidden flex-shrink-0" ,
64- ! isResizing && "transition-[width] duration-200" ,
82+ shouldAnimate && "transition-[width] duration-200" ,
6583 // Mobile: full width
6684 "max-md:border-l-0 max-md:border-t max-md:border-border-light max-md:w-full max-md:relative max-md:max-h-[50vh]"
6785 ) }
0 commit comments