diff --git a/src/components/sidebar/tree.js b/src/components/sidebar/tree.js index bd3d23ae..4a808a1c 100644 --- a/src/components/sidebar/tree.js +++ b/src/components/sidebar/tree.js @@ -125,10 +125,15 @@ const Tree = ({ edges }) => { treeData.items.forEach(item => { if (config.sidebar.collapsedNav && config.sidebar.collapsedNav.includes(item.url)) { defaultCollapsed[item.url] = true; + if (item.items.length !== 0) { // Assume page has children that should be collapsed + item.items.forEach(child => { + defaultCollapsed[child.url] = true; + })} } else { defaultCollapsed[item.url] = false; } }); + const [collapsed, setCollapsed] = useState(defaultCollapsed); const toggle = url => {