From 41afd6e2b211460a4ce5f20a132502d9a3f4bc58 Mon Sep 17 00:00:00 2001 From: Isarra Date: Thu, 29 Aug 2019 18:00:03 +0000 Subject: [PATCH] Fix close behaviour on click-toggle dropdowns Change-Id: I0d70773918b048288ed278adb3df7f23c2d561cd --- resources/main.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/resources/main.js b/resources/main.js index 28d5254..9ba8fc4 100644 --- a/resources/main.js +++ b/resources/main.js @@ -26,14 +26,16 @@ $( function () { * Click behaviour */ $dropdowns.on( 'click', function ( e ) { - var wasOpen = false; // Check if it's already open so we don't open it again if ( $( this ).hasClass( 'dropdown-active' ) ) { - wasOpen = true; - } - closeOpen(); - e.stopPropagation(); // stop hiding it! - if ( !wasOpen ) { + if ( $( e.target ).closest( $( 'h2, #p-variants-desktop h3' ) ).length > 0 ) { + // treat reclick on the header as a toggle + closeOpen(); + } + // Clicked inside an open menu; don't do anything + } else { + closeOpen(); + e.stopPropagation(); // stop hiding it! $( this ).addClass( 'dropdown-active' ); } } );