Skip to content

Commit 68d3456

Browse files
authored
Merge pull request #126 from mmu69/master
Update aria roles for bootstrap 5 menu
2 parents 0ecb302 + 9979a53 commit 68d3456

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/cloudscribe.Web.Navigation/Views/Shared/Bootstrap5NavigationNodeChildDropdownPartial.cshtml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
@inject IStringLocalizer<cloudscribe.Web.Navigation.MenuResources> sr
77
@if ((Model.TempNode != null) && (await Model.HasVisibleChildren(Model.TempNode)))
88
{
9-
<ul class="dropdown-menu" aria-labelledby="[email protected]">
9+
<ul role="menu" class="dropdown-menu" aria-labelledby="[email protected]">
1010
@foreach (var childNode in Model.TempNode.Children) {
1111
if (!await Model.ShouldAllowView(childNode)) { continue; }
1212

@@ -15,12 +15,12 @@
1515
continue;
1616
}
1717
if (!await Model.HasVisibleChildren(childNode)) {
18-
<li role="menuitem" class='@Model.GetClass(childNode.Value, "")'><a class="dropdown-item" href="@Url.Content(Model.AdjustUrl(childNode))">@Html.Raw(Model.GetIcon(childNode.Value))@sr[Model.AdjustText(childNode)]</a></li>
18+
<li role="none" class='@Model.GetClass(childNode.Value, "")'><a role="menuitem" class="dropdown-item" href="@Url.Content(Model.AdjustUrl(childNode))">@Html.Raw(Model.GetIcon(childNode.Value))@sr[Model.AdjustText(childNode)]</a></li>
1919
}
2020
else {
2121

22-
<li role="menuitem" aria-haspopup="menu" class='@Model.GetClass(childNode.Value, "dropdown ", "active", true)'>
23-
<a class="dropdown-item dropdown-toggle" href="@Url.Content(Model.AdjustUrl(childNode))">@Html.Raw(Model.GetIcon(childNode.Value))@sr[Model.AdjustText(childNode)] </a>
22+
<li role="none" class='@Model.GetClass(childNode.Value, "dropdown ", "active", true)'>
23+
<a role="menuitem" class="dropdown-item dropdown-toggle" aria-haspopup="true" href="@Url.Content(Model.AdjustUrl(childNode))">@Html.Raw(Model.GetIcon(childNode.Value))@sr[Model.AdjustText(childNode)] </a>
2424
@Model.UpdateTempNode(childNode) <partial name="Bootstrap5NavigationNodeChildDropdownPartial" model="@Model" /> @* recursion *@
2525
</li>
2626
}

src/cloudscribe.Web.Navigation/Views/Shared/Components/Navigation/Bootstrap5TopNavWithDropdowns.cshtml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<ul class="navbar-nav me-auto" role="menubar" aria-label="@sr["Top menu"]">
1010
@if (await Model.ShouldAllowView(Model.RootNode))
1111
{
12-
<li cwn-data-attributes="@Model.RootNode.Value.DataAttributes" class='@Model.GetClass(Model.RootNode.Value, "nav-item")'><a class="nav-link" href="@Url.Content(Model.AdjustUrl(Model.RootNode))">@Html.Raw(Model.GetIcon(Model.RootNode.Value))@sr[Model.AdjustText(Model.RootNode)]</a></li>
12+
<li role="none" cwn-data-attributes="@Model.RootNode.Value.DataAttributes" class='@Model.GetClass(Model.RootNode.Value, "nav-item")'><a role="menuitem" class="nav-link" href="@Url.Content(Model.AdjustUrl(Model.RootNode))">@Html.Raw(Model.GetIcon(Model.RootNode.Value))@sr[Model.AdjustText(Model.RootNode)]</a></li>
1313
}
1414

1515
@if (await Model.HasVisibleChildren(Model.RootNode))
@@ -19,12 +19,12 @@
1919
if (!await Model.ShouldAllowView(node)) { continue; }
2020
if (!await Model.HasVisibleChildren(node))
2121
{
22-
<li role="menuitem" class='@Model.GetClass(node.Value, "nav-item")' cwn-data-attributes="@node.Value.DataAttributes"><a class="nav-link" href="@Url.Content(Model.AdjustUrl(node))">@Html.Raw(Model.GetIcon(node.Value))@sr[Model.AdjustText(node)]</a></li>
22+
<li role="none" class='@Model.GetClass(node.Value, "nav-item")' cwn-data-attributes="@node.Value.DataAttributes"><a role="menuitem" class="nav-link" href="@Url.Content(Model.AdjustUrl(node))">@Html.Raw(Model.GetIcon(node.Value))@sr[Model.AdjustText(node)]</a></li>
2323
}
2424
else
2525
{
26-
<li role="menuitem" aria-haspopup="menu" class='@Model.GetClass(node.Value, "nav-item dropdown", "active", true)' cwn-data-attributes="@node.Value.DataAttributes">
27-
<a class="nav-link dropdown-toggle" id="[email protected]" aria-haspopup="true" aria-expanded="false" href="@Url.Content(Model.AdjustUrl(node))">@Html.Raw(Model.GetIcon(node.Value))@sr[Model.AdjustText(node)] </a>
26+
<li role="none" class='@Model.GetClass(node.Value, "nav-item dropdown", "active", true)' cwn-data-attributes="@node.Value.DataAttributes">
27+
<a role="menuitem" class="nav-link dropdown-toggle" id="[email protected]" aria-haspopup="true" aria-expanded="false" href="@Url.Content(Model.AdjustUrl(node))">@Html.Raw(Model.GetIcon(node.Value))@sr[Model.AdjustText(node)] </a>
2828
@Model.UpdateTempNode(node) <partial name="Bootstrap5NavigationNodeChildDropdownPartial" model="@Model" />
2929
</li>
3030
}

0 commit comments

Comments
 (0)