diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx index 1b46b0f1d0..3c2b8587b2 100644 --- a/apps/web/src/components/Sidebar.tsx +++ b/apps/web/src/components/Sidebar.tsx @@ -323,7 +323,7 @@ interface SidebarThreadRowProps { renamingCommittedRef: React.RefObject; confirmingArchiveThreadKey: string | null; setConfirmingArchiveThreadKey: React.Dispatch>; - confirmArchiveButtonRefs: React.RefObject>; + confirmArchiveButtonRefs: Map; handleThreadClick: ( event: React.MouseEvent, threadRef: ScopedThreadRef, @@ -608,9 +608,9 @@ export const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThr const handleConfirmArchiveRef = useCallback( (element: HTMLButtonElement | null) => { if (element) { - confirmArchiveButtonRefs.current.set(threadKey, element); + confirmArchiveButtonRefs.set(threadKey, element); } else { - confirmArchiveButtonRefs.current.delete(threadKey); + confirmArchiveButtonRefs.delete(threadKey); } }, [confirmArchiveButtonRefs, threadKey], @@ -636,7 +636,7 @@ export const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThr event.stopPropagation(); setConfirmingArchiveThreadKey(threadKey); requestAnimationFrame(() => { - confirmArchiveButtonRefs.current.get(threadKey)?.focus(); + confirmArchiveButtonRefs.get(threadKey)?.focus(); }); }, [confirmArchiveButtonRefs, setConfirmingArchiveThreadKey, threadKey], @@ -888,7 +888,7 @@ interface SidebarProjectThreadListProps { renamingCommittedRef: React.RefObject; confirmingArchiveThreadKey: string | null; setConfirmingArchiveThreadKey: React.Dispatch>; - confirmArchiveButtonRefs: React.RefObject>; + confirmArchiveButtonRefs: Map; attachThreadListAutoAnimateRef: (node: HTMLElement | null) => void; handleThreadClick: ( event: React.MouseEvent, @@ -1223,7 +1223,7 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec >("inherit"); const renamingCommittedRef = useRef(false); const renamingInputRef = useRef(null); - const confirmArchiveButtonRefs = useRef(new Map()); + const confirmArchiveButtonRefs = useMemo(() => new Map(), []); const memberProjectByScopedKey = useMemo( () => new Map( @@ -3246,23 +3246,23 @@ export default function Sidebar() { dragInProgressRef.current = false; }, []); - const animatedProjectListsRef = useRef(new WeakSet()); + const animatedProjectLists = useMemo(() => new WeakSet(), []); const attachProjectListAutoAnimateRef = useCallback((node: HTMLElement | null) => { - if (!node || animatedProjectListsRef.current.has(node)) { + if (!node || animatedProjectLists.has(node)) { return; } autoAnimate(node, SIDEBAR_LIST_ANIMATION_OPTIONS); - animatedProjectListsRef.current.add(node); - }, []); + animatedProjectLists.add(node); + }, [animatedProjectLists]); - const animatedThreadListsRef = useRef(new WeakSet()); + const animatedThreadLists = useMemo(() => new WeakSet(), []); const attachThreadListAutoAnimateRef = useCallback((node: HTMLElement | null) => { - if (!node || animatedThreadListsRef.current.has(node)) { + if (!node || animatedThreadLists.has(node)) { return; } autoAnimate(node, SIDEBAR_LIST_ANIMATION_OPTIONS); - animatedThreadListsRef.current.add(node); - }, []); + animatedThreadLists.add(node); + }, [animatedThreadLists]); const visibleThreads = useMemo( () => sidebarThreads.filter((thread) => thread.archivedAt === null),