fix: admin/shared: after adding an element under a collapsed folder, that was not displayed (the parent was not automatically expanded)
Massimo Melina committed
Sep 2, 2025 at 20:17 UTC
6107718ed4185d31c3ac3cab1db34e0f2afc6bcf
1 file changed
+3
admin/src/VfsTree.ts
+3
@@ -114,6 +114,9 @@ export default function VfsTree({ id2node, statusApi }:{ id2node: Map<string, Vf
114
setExpanded(expandAll ? Array.from(id2node.keys())
115
: ['/', ...vfs?.children?.length === 1 ? [vfs.children[0].id] : []]) // in case there's only one child, expand that too
116
}, [expandAll, Boolean(vfs)]) // vfs is undefined on first render, we want to be called again as soon as it is loaded first time and not at reloads
117
+ useEffect(() => {
118
+ setExpanded(was => _.uniq(was.concat(state.selectedFiles.map(x => x.parent?.id || ''))))
119
+ }, [state.vfs])
120
// be sure selected element is visible
121
const treeId = 'vfs'
122
const first = selectedFiles[0]