Skip to content

Commit

Permalink
Removed extra opening bracket. Fixed initial display of subnav based …
Browse files Browse the repository at this point in the history
…on .openSubMenu.
  • Loading branch information
diamondap committed Mar 18, 2024
1 parent c6909ce commit 6101ae5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
15 changes: 15 additions & 0 deletions static/js/modules/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,20 @@ export function initSidebar() {
sidebarSubnav.classList.toggle('is-sr-only');
sidebarMore.classList.toggle('is-hidden');
sidebarLess.classList.toggle('is-hidden');

// The following is for aria keyboard navigation. We don't want
// assistive technologies to tab into a hidden sub-menu. Setting
// both aria-expanded and display=block/hidden gives us the
// correct behavior. Tabbing skips closed menu items but works
// on open ones. Part of the general accessibility card at
// https://trello.com/c/CEQ5jAe1
var subnavIsOpen = sidebarMore.classList.contains("is-hidden")
if (subnavIsOpen) {
sidebarToggle.setAttribute("aria-expanded", "true")
sidebarSubnav.style.display = "block"
} else {
sidebarToggle.setAttribute("aria-expanded", "false")
sidebarSubnav.style.display = "none"
}
});
}
9 changes: 4 additions & 5 deletions views/shared/_side_nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@
<li><a href="/users"><span class="material-icons" aria-hidden="true">people</span> Users</a></li>
{{ end }}

<li><a href="#sidebarSubnav" id="sidebarToggle">
<li><a href="#sidebarSubnav" id="sidebarToggle" aria-expanded="{{ if not .openSubMenu }}false{{ else }}true{{end}}" aria-controls="sidebarSubnav">
<span class="material-icons" aria-hidden="true">list</span>
<span class="more-options {{ if .openSubMenu }} is-hidden {{ end }}">More </span>
<span class="less-options {{ if not .openSubMenu }} is-hidden {{ end }}">Fewer </span>
&nbsp;Options
</a></li>

<li>
<ul id="sidebarSubnav" class="{{ if not .openSubMenu }} is-sr-only {{ end }}">
</a>

<ul id="sidebarSubnav" class="{{ if not .openSubMenu }} is-sr-only {{ end }}" style="{{ if not .openSubMenu }}display:none{{ else }}display:block{{end}}">
{{ if userCan .CurrentUser "FileRead" .CurrentUser.InstitutionID }}
<li><a href="/files?state=A"><span class="material-icons" aria-hidden="true">insert_drive_file</span> Files</a></li>
{{ end }}
Expand Down

0 comments on commit 6101ae5

Please sign in to comment.