Fix close behaviour on click-toggle dropdowns

Change-Id: I0d70773918b048288ed278adb3df7f23c2d561cd
isekai
Isarra 5 years ago
parent 7f87813bc3
commit 41afd6e2b2

@ -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' );
}
} );

Loading…
Cancel
Save