Skip to content

Commit

Permalink
fix(client): expand all parent nodes on inspecting component tree (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
webfansplz authored Jan 4, 2024
1 parent 4b857d4 commit 66a298b
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions packages/client/src/pages/components.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ const selectedComponentTreeNode = computed<ComponentTreeNode>(() => {
find(treeNode.value)
return res[0]
})
const treeNodeIdLinkedList = computed<string[][]>(() => {
const res: string[][] = []
const find = (treeNode: ComponentTreeNode[], linkedList: string[] = []) => {
treeNode.forEach((item) => {
res.push([...linkedList, item.id])
if (item.children?.length)
find(item.children, [...linkedList, item.id])
})
}
find(treeNode.value)
return res
})
// selected component file path
const selectedComponentFilePath = computed(() => selectedComponentTreeNode.value?.file ?? '')
Expand Down Expand Up @@ -127,9 +141,22 @@ function inspectComponentInspector() {
selectedComponentTree.value = data.id
selectComponentTree(data.id)
const linkedList = componentTreeLinkedList.value[data.id]
linkedList.forEach((id) => {
componentTreeCollapseMap.value[id] = true
})
if (linkedList) {
linkedList.forEach((id) => {
componentTreeCollapseMap.value[id] = true
})
}
else {
treeNodeIdLinkedList.value.forEach((item) => {
let index = item.indexOf(data.id)
if (index > -1) {
while (index >= 0) {
componentTreeCollapseMap.value[item[index]] = true
index--
}
}
})
}
}).finally(() => {
bridge.value.emit('toggle-panel', true)
})
Expand Down

0 comments on commit 66a298b

Please sign in to comment.