From 236c8fa656934418624af4e16e5b8a8ba5ab0a26 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Mon, 3 Nov 2025 06:19:04 -0800 Subject: [PATCH] Fix sidebar reselection after dragging non-selelected item or renaming --- src-web/components/Sidebar.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src-web/components/Sidebar.tsx b/src-web/components/Sidebar.tsx index 8393953c..478aa926 100644 --- a/src-web/components/Sidebar.tsx +++ b/src-web/components/Sidebar.tsx @@ -57,7 +57,7 @@ import { InlineCode } from './core/InlineCode'; import type { InputHandle } from './core/Input'; import { Input } from './core/Input'; import { LoadingIcon } from './core/LoadingIcon'; -import { collapsedFamily, isSelectedFamily } from './core/tree/atoms'; +import { collapsedFamily, isSelectedFamily, selectedIdsFamily } from './core/tree/atoms'; import type { TreeNode } from './core/tree/common'; import type { TreeHandle, TreeProps } from './core/tree/Tree'; import { Tree } from './core/tree/Tree'; @@ -164,8 +164,10 @@ function Sidebar({ className }: { className?: string }) { if (n == null) return; const activeId = jotaiStore.get(activeIdAtom); if (activeId == null) return; + const selectedIds = jotaiStore.get(selectedIdsFamily(treeId)); + if (selectedIds.length > 0) return; n.selectItem(activeId); - }, []); + }, [treeId]); // Ensure active id is always selected when it changes useEffect(() => {