From eb231bf01aa8c2133427e2745b5f92a708af82ee Mon Sep 17 00:00:00 2001 From: Anton Wilhelm Date: Thu, 12 Sep 2019 17:10:16 +0200 Subject: [PATCH] fix($theme-default): Expand nested sidebar groups (#1540) --- .../theme-default/components/SidebarLinks.vue | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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 +}