Skip to content

Commit

Permalink
Fix vuejs#1497 expanad nested sidebar items initially
Browse files Browse the repository at this point in the history
  • Loading branch information
devtonhere committed Apr 13, 2019
1 parent 23b0ce3 commit 290142a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/@vuepress/theme-default/components/SidebarLinks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,23 @@ export default {
function resolveOpenGroupIndex (route, items) {
for (let i = 0; i < items.length; i++) {
const item = items[i]
if (item.type === 'group' && item.children.some(c => c.type === 'page' && isActive(route, c.path))) {
if (descendantIsActive(route, item)) {
return i
}
}
return -1
}
function descendantIsActive (route, item) {
if (item.type === 'group') {
return item.children.some(c => {
if (c.type === 'group') {
return descendantIsActive(route, c)
} else {
return c.type === 'page' && isActive(route, c.path)
}
})
}
return false
}
</script>

0 comments on commit 290142a

Please sign in to comment.