From 3ab9fcade4e485194c53f72c69172a879bbab22d Mon Sep 17 00:00:00 2001 From: echojoshchen <48116767+echojoshchen@users.noreply.github.com> Date: Thu, 18 Feb 2021 10:35:59 -0500 Subject: [PATCH] fix($default-theme): sidebar groups are not opened when directly navigating to these pages (fix #2564) (#2565) --- packages/@vuepress/theme-default/components/SidebarLinks.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/@vuepress/theme-default/components/SidebarLinks.vue b/packages/@vuepress/theme-default/components/SidebarLinks.vue index ea084e25c4..55e62885eb 100644 --- a/packages/@vuepress/theme-default/components/SidebarLinks.vue +++ b/packages/@vuepress/theme-default/components/SidebarLinks.vue @@ -90,13 +90,16 @@ function resolveOpenGroupIndex (route, items) { function descendantIsActive (route, item) { if (item.type === 'group') { - return item.children.some(child => { + const childIsActive = item.path && isActive(route, item.path) + const grandChildIsActive = item.children.some(child => { if (child.type === 'group') { return descendantIsActive(route, child) } else { return child.type === 'page' && isActive(route, child.path) } }) + + return childIsActive || grandChildIsActive } return false }