Skip to content

Commit eb51848

Browse files
committed
fix: use watchEffect to expand dirs
1 parent b208bd8 commit eb51848

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

app/components/diff/FileTree.vue

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,18 @@ function isNodeActive(node: DiffTreeNode): boolean {
8282
8383
const expandedDirs = ref<Set<string>>(new Set())
8484
85-
// Auto-expand all directories on mount (only at root level)
86-
onMounted(() => {
87-
if (props.depth === undefined || props.depth === 0) {
88-
function collectDirs(nodes: DiffTreeNode[]) {
89-
for (const node of nodes) {
90-
if (node.type === 'directory') {
91-
expandedDirs.value.add(node.path)
92-
if (node.children) collectDirs(node.children)
93-
}
94-
}
85+
function collectDirs(nodes: DiffTreeNode[]) {
86+
for (const node of nodes) {
87+
if (node.type === 'directory') {
88+
expandedDirs.value.add(node.path)
89+
if (node.children) collectDirs(node.children)
9590
}
91+
}
92+
}
93+
94+
// Auto-expand all directories eagerly (runs on both SSR and client)
95+
watchEffect(() => {
96+
if (props.depth === undefined || props.depth === 0) {
9697
collectDirs(tree.value)
9798
}
9899
})

0 commit comments

Comments
 (0)