From 223eda612bf3d75bd6d3c0fd193ceb83221cbe7f Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Mon, 10 Aug 2020 15:42:41 -0400 Subject: [PATCH 1/2] Fix sidebar expansion for subheading groups --- packages/@vuepress/theme-default/components/SidebarLinks.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@vuepress/theme-default/components/SidebarLinks.vue b/packages/@vuepress/theme-default/components/SidebarLinks.vue index ea084e25c4..5c1fc47185 100644 --- a/packages/@vuepress/theme-default/components/SidebarLinks.vue +++ b/packages/@vuepress/theme-default/components/SidebarLinks.vue @@ -96,7 +96,7 @@ function descendantIsActive (route, item) { } else { return child.type === 'page' && isActive(route, child.path) } - }) + }) || item.path && isActive(route, item.path) } return false } From c2436f0e3853c3db6896ca9fd5e21a3388f8fcac Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Thu, 18 Feb 2021 08:15:50 -0500 Subject: [PATCH 2/2] Add variable names to clarify code --- .../@vuepress/theme-default/components/SidebarLinks.vue | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/@vuepress/theme-default/components/SidebarLinks.vue b/packages/@vuepress/theme-default/components/SidebarLinks.vue index 5c1fc47185..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) } - }) || item.path && isActive(route, item.path) + }) + + return childIsActive || grandChildIsActive } return false }