Hello @krzd7,
Thank you for the suggestion. We have the plan to add functionality if click outside the flex menu, it will be closed. Similar to the Advanced Post Module Demo. We may not add the exact feature suggested by you, but you can try following code.
$(document).on('click', '.flexMenu-popup a', function() {
$('li.flexMenu-viewMore > a').trigger('click');
})
Best Regards!
Thread Starter
krzd7
(@krzd7)
Close by clicking outside the menu would be great.
Your code/suggestion works just fine, thanks a lot.
Most welcome!
Marking as resolved 🙂
Thread Starter
krzd7
(@krzd7)
I ended up implementing your idea of closing when clicking outside the flex menu, in case you want to add for the next update.
In fact, you’ll see that I’ve combined both ideas but commented the conditional that would close when clicking the link itself.
$(document).on('click', function(e) {
var flexMenuPopup = $('ul.flexMenu-popup');
if (!flexMenuPopup || !flexMenuPopup.is(":visible")) return;
var target = $(e.target);
if (!target /*|| target.parents('li.gutentor-filter-item').length*/ || !target.parents('ul.gutentor-filter-list').length) {
flexMenuPopup.hide();
}
});
@krzd7 thanks for the code, we added this code, I think result is the same
gDocument.click(function(e){
if( $(e.target).closest('li.flexMenu-viewMore ').length > 0 ) {
return false;
}
$('li.flexMenu-viewMore > a').trigger('click');
});
Thread Starter
krzd7
(@krzd7)
Hi,
I have tested this and, except for the sanity checks, it behaves the same. It triggers the click even if the flex menu is not open at all, but it does not seem to matter that much.
Thanks for adding this, I’ll remove my custom js once you guys update 🙂
Hello @krzd7 ,
Please update the Gutentor plugin to the latest version, now flex menu should close when click outside of it.
Best Regards!