Skip to content

Commit

Permalink
Merge pull request #87 from gsi-kevincarrera/feat/dropdown-closes-whe…
Browse files Browse the repository at this point in the history
…n-tabs-out

Feat: dropdown now closes when losing focus
  • Loading branch information
markteekman authored Jan 12, 2024
2 parents 3fca943 + 32a6476 commit b7366fb
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 b7366fb

Please sign in to comment.