Skip to content

Commit bfa476c

Browse files
authored
Ensure we set rootnavigation to the top level item, not the overall set (#1130)
* Ensure we set rootnavigation to the top level item, not the overall set * address compiler warnings and erroneous assignment
1 parent 47e8ce2 commit bfa476c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/Elastic.Markdown/IO/Navigation/DocumentationGroup.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ internal TableOfContentsTree(
116116
TreeCollector.Collect(source, this);
117117
}
118118

119+
protected override DocumentationGroup DefaultNavigation => this;
120+
119121
}
120122

121123
[DebuggerDisplay("Group >{Depth} {FolderName} ({NavigationItems.Count} items)")]
@@ -147,6 +149,8 @@ public class DocumentationGroup : INavigationGroup
147149

148150
public string FolderName { get; }
149151

152+
protected virtual DocumentationGroup DefaultNavigation => this;
153+
150154
protected DocumentationGroup(
151155
TableOfContentsTreeCollector treeCollector,
152156
BuildContext context,
@@ -178,7 +182,13 @@ protected DocumentationGroup(
178182
NavigationSource = navigationSource;
179183
_treeCollector = treeCollector;
180184
Depth = depth;
181-
toplevelTree ??= this;
185+
// Virtual calls don't use state so while ugly not an issue
186+
// We'll need to address this more structurally
187+
// ReSharper disable VirtualMemberCallInConstructor
188+
toplevelTree ??= DefaultNavigation;
189+
if (parent?.Depth == 0)
190+
toplevelTree = DefaultNavigation;
191+
// ReSharper enable VirtualMemberCallInConstructor
182192
NavigationRoot = toplevelTree;
183193
// ReSharper restore VirtualMemberCallInConstructor
184194
Index = ProcessTocItems(context, toplevelTree, index, lookups, depth, ref fileIndex, out var groups, out var files, out var navigationItems);

0 commit comments

Comments
 (0)