Skip to content

Commit 2303256

Browse files
author
Coffeephile
committed
Allow multiple expanded sidebar children
1 parent 667d9f4 commit 2303256

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

packages/@vuepress/theme-default/components/SidebarLinks.vue

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<SidebarGroup
88
v-if="item.type === 'group'"
99
:item="item"
10-
:open="i === openGroupIndex"
10+
:open="openGroupIndices.has(i)"
1111
:collapsable="item.collapsable || item.collapsible"
1212
:depth="depth"
1313
@toggle="toggleGroup(i)"
@@ -39,7 +39,7 @@ export default {
3939
4040
data () {
4141
return {
42-
openGroupIndex: 0
42+
openGroupIndices: new Set([0])
4343
}
4444
},
4545
@@ -60,12 +60,20 @@ export default {
6060
this.items
6161
)
6262
if (index > -1) {
63-
this.openGroupIndex = index
63+
this.openGroupIndices = new Set([index])
6464
}
6565
},
6666
6767
toggleGroup (index) {
68-
this.openGroupIndex = index === this.openGroupIndex ? -1 : index
68+
if (this.openGroupIndices.has(index)) {
69+
this.openGroupIndices.delete(index)
70+
} else {
71+
this.openGroupIndices.add(index)
72+
}
73+
74+
// a change to the set data structure does not trigger a UI update,
75+
// so force a repaint of the UI
76+
this.$forceUpdate()
6977
},
7078
7179
isActive (page) {

0 commit comments

Comments
 (0)