From 32a647608965489bc5e3fb6220431b79eaa790df Mon Sep 17 00:00:00 2001 From: Kevin Carrera Calzado Date: Fri, 29 Dec 2023 14:10:57 -0500 Subject: [PATCH] Feat: dropdown now closes when losing focus --- src/components/Navigation.astro | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/Navigation.astro b/src/components/Navigation.astro index ec44078..00b32a6 100644 --- a/src/components/Navigation.astro +++ b/src/components/Navigation.astro @@ -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) {