Skip to content

Commit 9d0a7b5

Browse files
committed
fix: disable CSS transition on tab switch to eliminate jank
1 parent 0f2f77b commit 9d0a7b5

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/browser/components/RightSidebar.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)