TypeScript
fix(web): prevent sidebar shelf animations from overlapping headers (#25384)
Brandon Julio Thenaro503bf7766808
diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsxindex 2eea84e86f9..01f62b5a544 100644--- a/apps/web/src/components/Sidebar.tsx+++ b/apps/web/src/components/Sidebar.tsx@@ -1990,10 +1990,17 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteRevedragState === null && sidebarListItems.length + visibleDraftSessionCount > 0;// Cache on both fields so layout-key changes trigger the effect even when animate is unchanged.const listMotionPass = { layoutKey: listMotionLayoutKey, animate: listMotionAnimate };+ const shelfExpansionKey = [workingShelfExpanded, snoozedShelfExpanded, settledShelfExpanded].join(+ ":",+ );+ const previousShelfExpansionKeyRef = useRef(shelfExpansionKey);// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- tells the list motion controller to animate or not after each layout-affecting commituseLayoutEffect(() => {- listMotionRef.current?.update(listMotionPass.animate);- }, [listMotionPass]);+ // Shelf rows would travel over stationary headers below the bottom-anchored shelf.+ const shelvesUnchanged = previousShelfExpansionKeyRef.current === shelfExpansionKey;+ previousShelfExpansionKeyRef.current = shelfExpansionKey;+ listMotionRef.current?.update(listMotionPass.animate && shelvesUnchanged);+ }, [listMotionPass, shelfExpansionKey]);const handleThreadDragOver = (event: DragOverEvent) => {const target = event.over? resolveSidebarDropTarget(sidebarListItems, String(event.active.id), String(event.over.id))