|
|
@@ -39,22 +39,8 @@ export function FolderTree({
|
|
|
onRefresh,
|
|
|
totalAssetCount,
|
|
|
}: Props) {
|
|
|
- // Auto-expand folders that contain the selected folder
|
|
|
- const initialExpanded = (() => {
|
|
|
- const s = new Set<string>();
|
|
|
- if (selectedFolderId !== null) {
|
|
|
- function markAncestors(f: FolderNode): boolean {
|
|
|
- if (f.id === selectedFolderId) return true;
|
|
|
- for (const child of f.children) {
|
|
|
- if (markAncestors(child)) { s.add(f.id); return true; }
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
- for (const f of folders) markAncestors(f);
|
|
|
- }
|
|
|
- return s;
|
|
|
- })();
|
|
|
- const [expanded, setExpanded] = useState<Set<string>>(initialExpanded);
|
|
|
+ // Default: all folders collapsed on first load
|
|
|
+ const [expanded, setExpanded] = useState<Set<string>>(new Set());
|
|
|
const [creatingIn, setCreatingIn] = useState<string | null>(null); // null = not creating, '__root__' = creating at root, string = creating in folder
|
|
|
const [newFolderName, setNewFolderName] = useState('');
|
|
|
const [renamingId, setRenamingId] = useState<string | null>(null);
|
|
|
@@ -327,22 +313,15 @@ export function FolderTree({
|
|
|
{hasFolders && (
|
|
|
<div className="flex items-center gap-0.5 px-1 mb-1">
|
|
|
<button
|
|
|
- onClick={() => setExpanded(new Set())}
|
|
|
- title="Collapse all"
|
|
|
- className="w-5 h-5 flex items-center justify-center rounded hover:bg-white/10 transition-colors shrink-0"
|
|
|
- style={{ color: 'var(--text-subtle)' }}
|
|
|
- >
|
|
|
- <svg className="w-3 h-3" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
|
|
|
- <path strokeLinecap="round" strokeLinejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5" />
|
|
|
- </svg>
|
|
|
- </button>
|
|
|
- <button
|
|
|
- onClick={() => setExpanded(allFolderIds)}
|
|
|
- title="Expand all"
|
|
|
+ onClick={() => setExpanded(expanded.size > 0 ? new Set() : allFolderIds)}
|
|
|
+ title={expanded.size > 0 ? 'Collapse all' : 'Expand all'}
|
|
|
className="w-5 h-5 flex items-center justify-center rounded hover:bg-white/10 transition-colors shrink-0"
|
|
|
style={{ color: 'var(--text-subtle)' }}
|
|
|
>
|
|
|
- <svg className="w-3 h-3" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
|
|
|
+ <svg
|
|
|
+ className={`w-3 h-3 transition-transform ${expanded.size > 0 ? 'rotate-0' : 'rotate-180'}`}
|
|
|
+ fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}
|
|
|
+ >
|
|
|
<path strokeLinecap="round" strokeLinejoin="round" d="M4.5 15.75l7.5-7.5 7.5 7.5" />
|
|
|
</svg>
|
|
|
</button>
|