Skip to content

Commit 503bf77

Browse files
fix(web): prevent sidebar shelf animations from overlapping headers (pingdotgg#25384)
Co-authored-by: maria-rcks <[email protected]>
1 parent ef6e05e commit 503bf77

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

‎apps/web/src/components/Sidebar.tsx‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1990,10 +1990,17 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
19901990
dragState === null && sidebarListItems.length + visibleDraftSessionCount > 0;
19911991
// Cache on both fields so layout-key changes trigger the effect even when animate is unchanged.
19921992
const listMotionPass = { layoutKey: listMotionLayoutKey, animate: listMotionAnimate };
1993+
const shelfExpansionKey = [workingShelfExpanded, snoozedShelfExpanded, settledShelfExpanded].join(
1994+
":",
1995+
);
1996+
const previousShelfExpansionKeyRef = useRef(shelfExpansionKey);
19931997
// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- tells the list motion controller to animate or not after each layout-affecting commit
19941998
useLayoutEffect(() => {
1995-
listMotionRef.current?.update(listMotionPass.animate);
1996-
}, [listMotionPass]);
1999+
// Shelf rows would travel over stationary headers below the bottom-anchored shelf.
2000+
const shelvesUnchanged = previousShelfExpansionKeyRef.current === shelfExpansionKey;
2001+
previousShelfExpansionKeyRef.current = shelfExpansionKey;
2002+
listMotionRef.current?.update(listMotionPass.animate && shelvesUnchanged);
2003+
}, [listMotionPass, shelfExpansionKey]);
19972004
const handleThreadDragOver = (event: DragOverEvent) => {
19982005
const target = event.over
19992006
? resolveSidebarDropTarget(sidebarListItems, String(event.active.id), String(event.over.id))

0 commit comments

Comments
 (0)