diff --git a/static/scripts/loggedin.js b/static/scripts/loggedin.js index 4cead872c3..876f4a2cd8 100644 --- a/static/scripts/loggedin.js +++ b/static/scripts/loggedin.js @@ -63,11 +63,17 @@ function toggleSidebar() { const sidebar = document.querySelector('.sidebar'); const overlay = document.querySelector('.overlay'); const contentDiv = document.querySelector('.content-min-height'); + const sidebarItems = document.querySelectorAll('.sidebar-item'); + const sidebarSubitems = document.querySelectorAll('.subitem'); + const legalLinks = document.querySelectorAll('.legal-link'); if (sidebar) { if (sidebar.classList.contains('hidden')) { sidebar.classList.remove('hidden'); sidebar.classList.add('visible'); + toggleTabindexOnSidebarItems(sidebarItems, 0); + toggleTabindexOnSidebarItems(legalLinks, 0); + toggleTabindexOnSidebarItems(sidebarSubitems, 0); if (window.innerWidth <= 1279) { overlay.style.display = "block"; @@ -78,6 +84,9 @@ function toggleSidebar() { } else { sidebar.classList.remove('visible'); sidebar.classList.add('hidden'); + toggleTabindexOnSidebarItems(sidebarItems, -1); + toggleTabindexOnSidebarItems(legalLinks, -1); + toggleTabindexOnSidebarItems(sidebarSubitems, -1); if (window.innerWidth <= 1279) { overlay.style.display = "none"; @@ -104,6 +113,13 @@ function toggleSidebar() { } } +function toggleTabindexOnSidebarItems(elements, tabindex) { + [].forEach.call(elements, function (el) { + el.setAttribute("tabindex", tabindex); + el.setAttribute("aria-hidden", true); + }); +} + function toggleSidebarOnWindowWidth(sidebar) { const overlay = document.querySelector('.overlay');