Skip to content

Commit

Permalink
Allow multiple expanded sidebar children
Browse files Browse the repository at this point in the history
  • Loading branch information
Coffeephile committed Jul 17, 2019
1 parent 667d9f4 commit 2303256
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions packages/@vuepress/theme-default/components/SidebarLinks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<SidebarGroup
v-if="item.type === 'group'"
:item="item"
:open="i === openGroupIndex"
:open="openGroupIndices.has(i)"
:collapsable="item.collapsable || item.collapsible"
:depth="depth"
@toggle="toggleGroup(i)"
Expand Down Expand Up @@ -39,7 +39,7 @@ export default {
data () {
return {
openGroupIndex: 0
openGroupIndices: new Set([0])
}
},
Expand All @@ -60,12 +60,20 @@ export default {
this.items
)
if (index > -1) {
this.openGroupIndex = index
this.openGroupIndices = new Set([index])
}
},
toggleGroup (index) {
this.openGroupIndex = index === this.openGroupIndex ? -1 : index
if (this.openGroupIndices.has(index)) {
this.openGroupIndices.delete(index)
} else {
this.openGroupIndices.add(index)
}
// a change to the set data structure does not trigger a UI update,
// so force a repaint of the UI
this.$forceUpdate()
},
isActive (page) {
Expand Down

0 comments on commit 2303256

Please sign in to comment.