Skip to content

Commit ac0284b

Browse files
committed
Fix hx-select-oob for nav crosslinks
1 parent 37a224f commit ac0284b

File tree

7 files changed

+13
-1
lines changed

7 files changed

+13
-1
lines changed

src/Elastic.ApiExplorer/Landing/LandingNavigationItem.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public class LandingNavigationItem : IApiGroupingNavigationItem<ApiLanding, INav
3333
public IReadOnlyCollection<INavigationItem> NavigationItems { get; set; } = [];
3434
public INodeNavigationItem<INavigationModel, INavigationItem>? Parent { get; set; }
3535
public int NavigationIndex { get; set; }
36+
public bool IsCrossLink => false; // API landing items are never cross-links
3637
public string Url { get; }
3738
public bool Hidden => false;
3839

@@ -83,6 +84,7 @@ public abstract class ApiGroupingNavigationItem<TGroupingModel, TNavigationItem>
8384
public bool Hidden => false;
8485
/// <inheritdoc />
8586
public int NavigationIndex { get; set; }
87+
public bool IsCrossLink => false; // API grouping items are never cross-links
8688

8789
/// <inheritdoc />
8890
public int Depth => 0;
@@ -141,6 +143,7 @@ public class EndpointNavigationItem(ApiEndpoint endpoint, IRootNavigationItem<IA
141143

142144
/// <inheritdoc />
143145
public int NavigationIndex { get; set; }
146+
public bool IsCrossLink => false; // API endpoint items are never cross-links
144147

145148
/// <inheritdoc />
146149
public int Depth => 0;

src/Elastic.ApiExplorer/Operations/OperationNavigationItem.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,6 @@ IApiGroupingNavigationItem<IApiGroupingModel, INavigationItem> parent
7070
public INodeNavigationItem<INavigationModel, INavigationItem>? Parent { get; set; }
7171

7272
public int NavigationIndex { get; set; }
73+
public bool IsCrossLink => false; // API operations are never cross-links
7374

7475
}

src/Elastic.Documentation.Site/Navigation/INavigationItem.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ public interface INavigationItem
3434
bool Hidden { get; }
3535

3636
int NavigationIndex { get; set; }
37+
38+
/// Gets whether this navigation item is a cross-link to another repository.
39+
bool IsCrossLink { get; }
3740
}
3841

3942
/// Represents a leaf node in the navigation tree with associated model data.

src/Elastic.Documentation.Site/Navigation/_TocTreeNav.cshtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,11 @@
7979
}
8080
else if (item is ILeafNavigationItem<INavigationModel> leaf)
8181
{
82+
var hasSameTopLevelGroup = !leaf.IsCrossLink && (Model.IsPrimaryNavEnabled && leaf.NavigationRoot.Id == Model.RootNavigationId || true);
8283
<li class="flex group/li pr-8 @(isTopLevel ? "font-semibold mt-6" : "mt-4")">
8384
<a
8485
href="@leaf.Url"
85-
@Htmx.GetNavHxAttributes(Model.IsPrimaryNavEnabled && leaf.NavigationRoot.Id == Model.RootNavigationId || true)
86+
@Htmx.GetNavHxAttributes(hasSameTopLevelGroup)
8687
class="sidebar-link grow group-[.current]/li:text-blue-elastic!"
8788
>
8889
@leaf.NavigationTitle

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,6 @@ private string GetNavigationTitleFromUrl(string url)
6363
public string Url => ResolvedUrl ?? _url; public string NavigationTitle { get; }
6464
public int NavigationIndex { get; set; }
6565
public bool Hidden { get; }
66+
public bool IsCrossLink => true; // This is always a cross-link
6667
public INavigationModel Model => null!; // Cross-link has no local model
6768
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public class DocumentationGroup : INodeNavigationItem<MarkdownFile, INavigationI
3232

3333
public int NavigationIndex { get; set; }
3434

35+
public bool IsCrossLink => false; // Documentation groups are never cross-links
36+
3537
private IReadOnlyCollection<MarkdownFile> FilesInOrder { get; }
3638

3739
private IReadOnlyCollection<DocumentationGroup> GroupsInOrder { get; }

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ public record FileNavigationItem(MarkdownFile Model, DocumentationGroup Group, b
1616
public string Url => Model.Url;
1717
public string NavigationTitle => Model.NavigationTitle;
1818
public int NavigationIndex { get; set; }
19+
public bool IsCrossLink => false; // File navigation items are never cross-links
1920
}

0 commit comments

Comments
 (0)