fix: screen reader styles, label, text updates

This commit is contained in:
Cory Dransfeldt 2024-06-19 07:49:17 -07:00
parent 435396f0fe
commit 9c394238e0
No known key found for this signature in database
5 changed files with 23 additions and 3 deletions

View file

@ -1,5 +1,6 @@
window.addEventListener('load', () => {
const menuInput = document.getElementById('menu-toggle')
const menuLabelText = document.getElementById('menu-label-text')
const menuButtonContainer = document.querySelector('.menu-button-container')
const menuItems = document.querySelectorAll('.menu-primary li[role="menu-item"]')
const isMobile = () => window.innerWidth <= 768
@ -12,6 +13,14 @@ window.addEventListener('load', () => {
const link = item.querySelector('a')
if (link) link.setAttribute('tabindex', isMobile() && !isExpanded ? '-1' : '0')
})
if(isExpanded) {
menuLabelText.textContent = 'Close mobile menu'
}
if (!isExpanded) {
menuLabelText.textContent = 'Open mobile menu'
menuButtonContainer.focus()
}
}
updateTabIndex()