Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions client/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ export function Sidebar({
onImportFile,
onImportFolder,
}: Props) {
const [collapsed, setCollapsed] = useState<Record<string, boolean>>({});
// Tracks which collections/folders are expanded; absent keys are collapsed
// (the default), so the tree opens collapsed.
const [expanded, setExpanded] = useState<Record<string, boolean>>({});
const [menu, setMenu] = useState<MenuState | null>(null);
const [importMenu, setImportMenu] = useState<{ x: number; y: number } | null>(null);
const [drag, setDrag] = useState<DragItem | null>(null);
Expand All @@ -109,7 +111,7 @@ export function Sidebar({
JSON.stringify(sel) === JSON.stringify(selection);

const toggle = (key: string) =>
setCollapsed((c) => ({ ...c, [key]: !c[key] }));
setExpanded((c) => ({ ...c, [key]: !c[key] }));

/** Whether the dragged item may drop into the given node (not a no-op/cycle). */
function canDrop(item: DragItem, cid: string, folderPath: string[]): boolean {
Expand Down Expand Up @@ -286,7 +288,7 @@ export function Sidebar({
{...dropTarget(collectionId, folderPath, key)}
>
<button className="icon-btn chevron" onClick={() => toggle(key)}>
{collapsed[key] ? '' : ''}
{expanded[key] ? '' : ''}
</button>
<button className="row-label" onClick={() => onSelect(sel)}>
<span className="folder-tag">▥</span>
Expand All @@ -300,7 +302,7 @@ export function Sidebar({
</button>
</div>
{!collapsed[key] &&
{expanded[key] &&
renderChildren(collectionId, folderPath, folder, depth + 1)}
</div>
);
Expand Down Expand Up @@ -330,7 +332,7 @@ export function Sidebar({
<div key={collection.id}>
<div className={cls} {...dropTarget(collection.id, [], key)}>
<button className="icon-btn chevron" onClick={() => toggle(key)}>
{collapsed[key] ? '' : ''}
{expanded[key] ? '' : ''}
</button>
<button
className="row-label"
Expand All @@ -355,7 +357,7 @@ export function Sidebar({
</button>
</div>
{!collapsed[key] && renderChildren(collection.id, [], collection, 1)}
{expanded[key] && renderChildren(collection.id, [], collection, 1)}
</div>
);
}
Expand Down
3 changes: 2 additions & 1 deletion client/src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ pre,
}

.folder-tag {
font-size: 0.78rem;
font-size: 0.95rem;
color: var(--text-muted);
}

Expand Down Expand Up @@ -659,6 +659,7 @@ input[type='radio'] {
border-radius: 4px;
padding: 3px 7px;
line-height: 1;
font-size: 1.05rem;
}

.icon-btn:hover {
Expand Down
Loading