Skip to content

Commit 3a28691

Browse files
committed
feat: alt-click to expand all sub-nodes
1 parent b3dd744 commit 3a28691

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

packages/app-frontend/src/features/components/ComponentTreeNode.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,14 @@ export default defineComponent({
140140
}
141141
}
142142
143+
function switchToggle (event) {
144+
if (event.altKey) {
145+
toggle(true, !expanded.value)
146+
} else {
147+
toggle()
148+
}
149+
}
150+
143151
return {
144152
toggleEl,
145153
sortedChildren,
@@ -148,7 +156,7 @@ export default defineComponent({
148156
selected,
149157
select,
150158
expanded,
151-
toggle,
159+
switchToggle,
152160
highlight,
153161
unhighlight,
154162
selectNextSibling,
@@ -180,7 +188,7 @@ export default defineComponent({
180188
:class="{
181189
'invisible': !instance.hasChildren
182190
}"
183-
@click.stop="toggle()"
191+
@click.stop="switchToggle"
184192
>
185193
<span
186194
:class="{

packages/app-frontend/src/features/components/composable/components.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,18 @@ export function useComponent (instance: Ref<ComponentTreeNode>) {
136136
const isExpanded = computed(() => isComponentOpen(instance.value.id))
137137
const isExpandedUndefined = computed(() => expandedMap.value[instance.value.id] == null)
138138

139-
function toggleExpand () {
140-
if (!instance.value.hasChildren) return
141-
setComponentOpen(instance.value.id, !isExpanded.value)
142-
if (isComponentOpen(instance.value.id)) {
143-
requestComponentTree(instance.value.id)
139+
function toggleExpand (recursively = false, value?, child?) {
140+
const treeNode = child || instance.value
141+
if (!treeNode.hasChildren) return
142+
const isOpen = value === undefined ? !isExpanded.value : value
143+
setComponentOpen(treeNode.id, isOpen)
144+
if (isComponentOpen(treeNode.id)) {
145+
requestComponentTree(treeNode.id)
146+
}
147+
if (recursively) {
148+
treeNode.children.forEach(child => {
149+
toggleExpand(recursively, value, child)
150+
})
144151
}
145152
}
146153

0 commit comments

Comments
 (0)