GeezerVison is showing github.com — fix(web): prevent sidebar shelf animations from overlapping headers (… · Pipyakas/t3code@f07b569
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: apps/web/src/components/Sidebar.tsx +9-2Lines changed: 9 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1990,10 +1990,17 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve |
1990 | 1990 | dragState === null && sidebarListItems.length + visibleDraftSessionCount > 0; |
1991 | 1991 | // Cache on both fields so layout-key changes trigger the effect even when animate is unchanged. |
1992 | 1992 | const listMotionPass = { layoutKey: listMotionLayoutKey, animate: listMotionAnimate }; |
| 1993 | + const shelfExpansionKey = [workingShelfExpanded, snoozedShelfExpanded, settledShelfExpanded].join( |
| 1994 | + ":", |
| 1995 | + ); |
| 1996 | + const previousShelfExpansionKeyRef = useRef(shelfExpansionKey); |
1993 | 1997 | // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- tells the list motion controller to animate or not after each layout-affecting commit |
1994 | 1998 | 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]); |
1997 | 2004 | const handleThreadDragOver = (event: DragOverEvent) => { |
1998 | 2005 | const target = event.over |
1999 | 2006 | ? resolveSidebarDropTarget(sidebarListItems, String(event.active.id), String(event.over.id)) |
|