Recursively collapse during "coolapse all"

This commit is contained in:
Gregory Schier
2025-11-05 10:12:10 -08:00
parent e264c50427
commit ef86c1d189

View File

@@ -223,10 +223,12 @@ function Sidebar({ className }: { className?: string }) {
for (const n of node.children ?? []) { for (const n of node.children ?? []) {
if (n.item.model !== 'folder') continue; if (n.item.model !== 'folder') continue;
collapsed[n.item.id] = true; collapsed[n.item.id] = true;
collapsed = next(n, collapsed);
} }
return collapsed; return collapsed;
}; };
jotaiStore.set(collapsedFamily(treeId), next(tree, {})); const collapsed = next(tree, {});
jotaiStore.set(collapsedFamily(treeId), collapsed);
}, },
}, },
'sidebar.selected.delete': { 'sidebar.selected.delete': {
@@ -435,7 +437,7 @@ function Sidebar({ className }: { className?: string }) {
aria-hidden={hidden ?? undefined} aria-hidden={hidden ?? undefined}
className={classNames(className, 'h-full grid grid-rows-[auto_minmax(0,1fr)_auto]')} className={classNames(className, 'h-full grid grid-rows-[auto_minmax(0,1fr)_auto]')}
> >
<div className="w-full px-3 pt-3 grid grid-cols-[minmax(0,1fr)_auto] items-center -mr-2.5"> <div className="w-full pl-3 pr-0.5 pt-3 grid grid-cols-[minmax(0,1fr)_auto] items-center">
{(tree.children?.length ?? 0) > 0 && ( {(tree.children?.length ?? 0) > 0 && (
<> <>
<Input <Input
@@ -485,7 +487,6 @@ function Sidebar({ className }: { className?: string }) {
size="xs" size="xs"
className="ml-0.5 text-text-subtle hover:text-text" className="ml-0.5 text-text-subtle hover:text-text"
icon="ellipsis_vertical" icon="ellipsis_vertical"
hotkeyAction="sidebar.collapse_all"
title="Show sidebar actions menu" title="Show sidebar actions menu"
/> />
</Dropdown> </Dropdown>
@@ -630,7 +631,7 @@ const sidebarTreeAtom = atom<[TreeNode<SidebarModel>, FieldDef[]] | null>((get)
const root: TreeNode<SidebarModel> = { const root: TreeNode<SidebarModel> = {
item: activeWorkspace, item: activeWorkspace,
parent: null, parent: null,
children: [], children: [],
depth: 0, depth: 0,
}; };