From c24e35c4e836413d01a53a3190146d778c1a1f6a Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 14 Jan 2025 21:05:26 +0100 Subject: [PATCH] final solving of menu hover bug --- app/static/js/navigation.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/app/static/js/navigation.js b/app/static/js/navigation.js index 8591977..a9ddfe1 100644 --- a/app/static/js/navigation.js +++ b/app/static/js/navigation.js @@ -9,7 +9,6 @@ document.addEventListener('DOMContentLoaded', () => { function onMouseEnter() { clearTimeout(timeout); openMenu(item, isTopLevel); - refreshEventListeners(); } function onMouseLeave() { @@ -33,20 +32,18 @@ document.addEventListener('DOMContentLoaded', () => { } else { openMenu(item, isTopLevel); } - refreshEventListeners(); }); }); } - function refreshEventListeners() { + function addAllMenuEventListeners() { const updatedMenuItems = document.querySelectorAll('.nav-item.dropdown'); const updatedSubMenuItems = document.querySelectorAll('.dropdown-submenu'); addMenuEventListeners(updatedMenuItems, true); addMenuEventListeners(updatedSubMenuItems, false); } - addMenuEventListeners(menuItems, true); - addMenuEventListeners(subMenuItems, false); + addAllMenuEventListeners(); // Globale Klick-Listener, um Menüs zu schließen, wenn außerhalb geklickt wird document.addEventListener('click', () => { @@ -57,10 +54,10 @@ document.addEventListener('DOMContentLoaded', () => { item.classList.add('open'); const submenu = item.querySelector('.dropdown-menu'); if (submenu) { - adjustMenuPosition(submenu, item, isTopLevel); submenu.style.display = 'block'; submenu.style.opacity = '1'; submenu.style.visibility = 'visible'; + adjustMenuPosition(submenu, item, isTopLevel); } }