add aria-expanded when mobile nav shown

This commit is contained in:
rimu 2024-02-29 15:20:37 +13:00
parent 61830e630c
commit 394f46fde3
2 changed files with 5 additions and 2 deletions

View file

@ -23,8 +23,11 @@ window.addEventListener("load", function () {
function setupMobileNav() {
var navbarToggler = document.getElementById('navbar-toggler');
var navbarSupportedContent = document.getElementById('navbarSupportedContent');
navbarToggler.addEventListener("click", function(event) {
toggleClass('navbarSupportedContent', 'show_menu')
toggleClass('navbarSupportedContent', 'show_menu');
var isExpanded = navbarSupportedContent.classList.contains('show_menu');
navbarSupportedContent.setAttribute('aria-expanded', isExpanded ? 'true' : 'false');
});
}

View file

@ -116,7 +116,7 @@
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent" role="navigation">
<div class="collapse navbar-collapse" id="navbarSupportedContent" role="navigation" aria-expanded="false">
<ul class="nav navbar-nav ml-md-4">
{% if current_user.is_anonymous %}
<li class="nav-item dropdown{% if active_parent == 'home' %} active{% endif %}">