diff --git a/packages/@vuepress/theme-default/components/SidebarLinks.vue b/packages/@vuepress/theme-default/components/SidebarLinks.vue index dfdb0bef07..d6b5ff7cdb 100644 --- a/packages/@vuepress/theme-default/components/SidebarLinks.vue +++ b/packages/@vuepress/theme-default/components/SidebarLinks.vue @@ -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(child => { + if (child.type === 'group') { + return descendantIsActive(route, child) + } else { + return child.type === 'page' && isActive(route, child.path) + } + }) + } + return false +}