Skip to content

Commit

Permalink
fix: auto expand all
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando committed May 21, 2024
1 parent 78beda9 commit 006d9d2
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions src/components/custom/CCTreeView.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<template>
<v-treeview ref="treeview" open-all dense :items="items">
<v-treeview
v-if="items.length > 0"
ref="treeview"
open-all
dense
:items="items"
>
<template v-slot:label="{ item }">
<v-row class="ma-0 pa-0" dense>
<strong class="tree-item-name" style="white-space: pre-wrap">{{
Expand Down Expand Up @@ -88,12 +94,23 @@ export default {
default: 0,
},
},
data: () => ({}),
computed: {
items() {
return Array.isArray(this.value)
? this.value
: this.parseEntry(this.value)
data: () => ({
items: [],
}),
watch: {
value: {
immediate: true,
handler() {
if (Array.isArray(this.value)) {
this.items = this.value
} else {
// trick used to reset the treeview and expand all nodes on change
this.items = []
this.$nextTick(() => {
this.items = this.parseEntry(this.value)
})
}
},
},
},
methods: {
Expand Down

0 comments on commit 006d9d2

Please sign in to comment.