Description
- I confirm that this is an issue rather than a question.
Bug report
Group in sidebar is not expanded for deep nested children.
Version
1.0.0-alpha.44
Steps to reproduce
Open this page: https://hungry-yonath-bfd0a1.netlify.com/frameworks/non-jsx/vue.js.html
The group (Frameworks) in the sidebar is not expanded. You need to expand the first group manually. The second group (non-JSX) is already (correctly) expanded.
repro repo: https://github.com/timaschew/vuepress-nested-sidebar-demo
What is expected?
- Frameworks is expanded and
- non-JSX is expanded and
- the page Vue.js is active/highlighted
What is actually happening?
Frameworks is NOT expanded
Other relevant information
- Your OS: macOS
- Node.js version: 11.11
- Browser version: Chrome 72
- Is this a global or local install? Local
- Which package manager did you use for the install? npm
- Does this issue occur when all plugins are disabled? yes
I tried to fix the SidebarLinks.vue component by changing this code block:
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))) {
return i
}
}
with a flatten array of all nested children, but it didn't work.
Also I tried to trigger toggleGroup
within created ()
if it matches any nested children for the active route but that has affected the wrong group, it was the inner/second group which was then also collapsed.
So please give me a hint then I can provide a PR.
Related documentation:
I didn't saw this documented anywhere, but I just suggest to mention this explicitly in the docs to avoid surprising effects:
- If a group is expanded by clicking then every first child (up to the deepest level) is expanded automatically. All other siblings are not expanded.
- You cannot expand two groups at the same time if they are siblings.
- If you expand a path of nested groups which are just titles (don't are links) but you don't click on any link at the end within the path and then collapsing the top group and expanding it again the expanded state will be discarded. Except you've expanded a path which contains always the first child (see no.1)