Skip to content

Commit eb231bf

Browse files
timaschewkefranabg
authored andcommitted
fix($theme-default): Expand nested sidebar groups (#1540)
1 parent 1ba06ae commit eb231bf

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

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

+14-1
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,23 @@ export default {
7777
function resolveOpenGroupIndex (route, items) {
7878
for (let i = 0; i < items.length; i++) {
7979
const item = items[i]
80-
if (item.type === 'group' && item.children.some(c => c.type === 'page' && isActive(route, c.path))) {
80+
if (descendantIsActive(route, item)) {
8181
return i
8282
}
8383
}
8484
return -1
8585
}
86+
87+
function descendantIsActive (route, item) {
88+
if (item.type === 'group') {
89+
return item.children.some(child => {
90+
if (child.type === 'group') {
91+
return descendantIsActive(route, child)
92+
} else {
93+
return child.type === 'page' && isActive(route, child.path)
94+
}
95+
})
96+
}
97+
return false
98+
}
8699
</script>

0 commit comments

Comments
 (0)