From fe67b34f1a03d838df82a1307cf6467f994a8f3b Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Fri, 19 Feb 2021 16:56:13 +0000 Subject: [PATCH] [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 --- .../static/src/js/editor/wysiwyg_multizone.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/website/static/src/js/editor/wysiwyg_multizone.js b/addons/website/static/src/js/editor/wysiwyg_multizone.js index 42b102ba601..3f5f9c403bd 100644 --- a/addons/website/static/src/js/editor/wysiwyg_multizone.js +++ b/addons/website/static/src/js/editor/wysiwyg_multizone.js @@ -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)