Skip to content

Commit

Permalink
Close open menus on nav (#2010)
Browse files Browse the repository at this point in the history
  • Loading branch information
liamcmitchell authored Jan 8, 2025
1 parent 22103e7 commit 0b1328a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion assets/js/sidebar/sidebar-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,15 @@ function markCurrentHashInSidebar () {
if (!current) return

// Unset previous.
sidebar.querySelectorAll('li a[aria-selected]').forEach(element => {
sidebar.querySelectorAll('.full-list a[aria-selected]').forEach(element => {
element.removeAttribute('aria-selected')
})

// Close open menus.
sidebar.querySelectorAll('.full-list button[aria-expanded=true]').forEach(element => {
element.setAttribute('aria-expanded', false)
})

// Walk up parents, updating link, button and tab attributes.
let element = current.parentElement
while (element) {
Expand Down

0 comments on commit 0b1328a

Please sign in to comment.