Skip to content

Commit

Permalink
Feat: dropdown now closes when losing focus
Browse files Browse the repository at this point in the history
  • Loading branch information
gsi-kevincarrera committed Dec 29, 2023
1 parent 3fca943 commit 32a6476
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/components/Navigation.astro
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@ import logo from '../assets/img/logo.svg'
targetItem = currentDropdownMenu.parentNode
closeAllDropdownMenus()
}

if (key === 'Tab') {
const currentDropdownMenu = (currentDropdownList as Element).previousElementSibling

if (dropdownMenuItems.indexOf(currentDropdownMenuItem as HTMLLIElement) === dropdownMenuItems.length - 1) {
closeDropdownMenu(currentDropdownMenu)
}
}
}

if (targetItem) {
Expand Down

0 comments on commit 32a6476

Please sign in to comment.