Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix($theme-default): Expand nested sidebar groups #1540

Merged
merged 5 commits into from
Sep 12, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion packages/@vuepress/theme-default/components/SidebarLinks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
timaschew marked this conversation as resolved.
Show resolved Hide resolved
if (c.type === 'group') {
timaschew marked this conversation as resolved.
Show resolved Hide resolved
return descendantIsActive(route, c)
timaschew marked this conversation as resolved.
Show resolved Hide resolved
} else {
return c.type === 'page' && isActive(route, c.path)
timaschew marked this conversation as resolved.
Show resolved Hide resolved
}
})
}
return false
}
</script>