From 290142a356675c34c5ab47477141a2bd7d5d81f6 Mon Sep 17 00:00:00 2001 From: Anton Wilhelm Date: Sat, 13 Apr 2019 12:12:04 +0200 Subject: [PATCH] Fix #1497 expanad nested sidebar items initially --- .../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..1521b7e2ba 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(c => { + if (c.type === 'group') { + return descendantIsActive(route, c) + } else { + return c.type === 'page' && isActive(route, c.path) + } + }) + } + return false +}