From c1708b32656974a236f4a8adaa2320cda0635be5 Mon Sep 17 00:00:00 2001
From: nod_ <nod_@598310.no-reply.drupal.org>
Date: Wed, 17 Jul 2024 22:21:25 +0200
Subject: [PATCH] Issue #3461284 by mherchel, finnsky, quietone, nod_: Prevent
 simultaneous open/close on simultaneous click/hover

---
 core/modules/navigation/js/toolbar-popover.js | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/core/modules/navigation/js/toolbar-popover.js b/core/modules/navigation/js/toolbar-popover.js
index 026d85466e47..50fa58180ecd 100644
--- a/core/modules/navigation/js/toolbar-popover.js
+++ b/core/modules/navigation/js/toolbar-popover.js
@@ -9,6 +9,7 @@
 
 const POPOVER_OPEN_DELAY = 150;
 const POPOVER_CLOSE_DELAY = 400;
+const POPOVER_NO_CLICK_DELAY = 500;
 
 ((Drupal, once) => {
   Drupal.behaviors.navigationProcessPopovers = {
@@ -42,12 +43,17 @@ const POPOVER_CLOSE_DELAY = 400;
 
         const expandPopover = () => {
           popover.classList.add('toolbar-popover--expanded');
+          button.dataset.drupalNoClick = 'true';
           tooltip.removeAttribute('inert');
+          setTimeout(() => {
+            delete button.dataset.drupalNoClick;
+          }, POPOVER_NO_CLICK_DELAY);
         };
 
         const collapsePopover = () => {
           popover.classList.remove('toolbar-popover--expanded');
           tooltip.setAttribute('inert', true);
+          delete button.dataset.drupalNoClick;
         };
 
         /**
@@ -134,7 +140,10 @@ const POPOVER_CLOSE_DELAY = 400;
         button.addEventListener('click', (e) => {
           const state =
             e.currentTarget.getAttribute('aria-expanded') === 'false';
-          toggleState(state);
+
+          if (!e.currentTarget.dataset.drupalNoClick) {
+            toggleState(state);
+          }
         });
 
         // Listens events from sidebar.js.
-- 
GitLab