fix: admin/fs: on phone it was not possible to select home
Massimo Melina committed
Feb 23, 2024 at 15:03 UTC
08d9b6bcbeab5032fdc32d667865c17a6390592a
1 file changed
+3
-5
admin/src/VfsTree.ts
+3
-5
@@ -28,7 +28,7 @@ export default function VfsTree({ id2node, statusApi }:{ id2node: Map<string, Vf
28
// @ts-ignore the type declared on the lib doesn't seem to be compatible with useRef()
29
ref,
30
expanded,
31
- selected: selectedFiles.length ? selectedFiles.map(x => x.id) : ['/'],
31
+ selected: selectedFiles.map(x => x.id),
32
multiSelect: true,
33
id: treeId,
34
sx: {
@@ -38,7 +38,7 @@ export default function VfsTree({ id2node, statusApi }:{ id2node: Map<string, Vf
38
},
39
onNodeSelect(ev, ids) {
40
if (typeof ids === 'string') return // shut up ts
41
- state.selectedFiles = onlyTruthy(ids.filter(x => (selectedFiles.length || x !== '/') && x).map(id => id2node.get(id)))
41
+ state.selectedFiles = onlyTruthy(ids.map(id => id2node.get(id)))
42
}
43
}, recur(vfs as Readonly<VfsNode>))
44
@@ -48,14 +48,12 @@ export default function VfsTree({ id2node, statusApi }:{ id2node: Map<string, Vf
48
49
function recur(node: Readonly<VfsNode>): ReactElement {
50
let { id, name, isRoot } = node
51
- if (!id)
52
- debugger
51
const folder = node.type === 'folder'
52
const ref = useRef<HTMLLIElement | null>()
53
if (isRoot && ref.current)
54
ref.current.firstElementChild?.classList.toggle('Mui-selected', !(selectedFiles.length && !_.find(selectedFiles, { id: '/' })))
55
return h(TreeItem, {
58
- ref(el: any) { // workaround to permit drag&drop with mui5's tree
56
+ ref(el) { // workaround to permit drag&drop with mui5's tree
57
el?.addEventListener('focusin', (e: any) => e.stopImmediatePropagation())
58
ref.current = el
59
},