[IMP] website: keep dropdown open when clicked in navbar on edit mode

Before this commit, when a menu inside a dropdown was clicked, the dropdown
would close itself, making the menu impossible to be edited.
That was not really an issue as those menu could still be edited through the
menu editor dialog.

That behavior was already prevented for mega menu in order to be able to edit
them.

This commit adds the same behavior to regular dropdown menu. It is mandatory
for the following commit adding a popover on menu to edit them instead of the
dialog.

Part of https://github.com/odoo/odoo/pull/64756
task-2439860
This commit is contained in:
Romain Derie
2021-04-01 09:49:45 +00:00
committed by qsm-odoo
parent 9658cc2944
commit fe67b34f1a
@@ -55,18 +55,18 @@ var WysiwygMultizone = Wysiwyg.extend({
return self._saveElement(outerHTML, self.options.recordInfo, $el[0]);
};
// Mega menu initialization: handle dropdown openings by hand
var $megaMenuToggles = this.$('.o_mega_menu_toggle');
$megaMenuToggles.removeAttr('data-toggle').dropdown('dispose');
$megaMenuToggles.on('click.wysiwyg_multizone', ev => {
// Dropdown menu initialization: handle dropdown openings by hand
var $dropdownMenuToggles = this.$('.o_mega_menu_toggle, #top_menu_container .dropdown-toggle');
$dropdownMenuToggles.removeAttr('data-toggle').dropdown('dispose');
$dropdownMenuToggles.on('click.wysiwyg_multizone', ev => {
var $toggle = $(ev.currentTarget);
// Each time we toggle a dropdown, we will destroy the dropdown
// behavior afterwards to keep manual control of it
var dispose = ($els => $els.dropdown('dispose'));
// First hide all other mega menus
toggleDropdown($megaMenuToggles.not($toggle), false).then(dispose);
// First hide all other dropdown menus
toggleDropdown($dropdownMenuToggles.not($toggle), false).then(dispose);
// Then toggle the clicked one
toggleDropdown($toggle)