diff --git a/addons/web/static/src/legacy/js/core/menu.js b/addons/web/static/src/legacy/js/core/menu.js index 0563816e7d198857c60a98123694326d8b314b4a..5bac0cdba96d2344cff59f26bea24450981ef12b 100644 --- a/addons/web/static/src/legacy/js/core/menu.js +++ b/addons/web/static/src/legacy/js/core/menu.js @@ -97,6 +97,7 @@ export async function initAutoMoreMenu(el, options) { } function _adapt() { + el.dispatchEvent(new Event("autoMoreMenu.willAdapt", {bubbles: true})); if (options.loadingStyleClasses.length) { el.classList.add(...options.loadingStyleClasses); } @@ -202,6 +203,16 @@ export async function initAutoMoreMenu(el, options) { extraItemsToggle.appendChild(extraItemsToggleLink); extraItemsToggle.appendChild(dropdownMenu); el.insertBefore(extraItemsToggle, target); + // TODO Adapt in 16.0: The dropdown menu is closed when clicking inside + // the extra menu items. The goal here is to prevent this default + // behaviour on "edit" mode to allow correct editing of extra menu + // items, mega menu content... This should be simply replaced by the BS5 + // `autoClose` option. + if (window.jQuery && document.body.classList.contains("editor_enable")) { + $(extraItemsToggle).on("hide.bs.dropdown", e => { + return !e.clickEvent || !e.clickEvent.target.closest(".o_extra_menu_items"); + }); + } return dropdownMenu; } diff --git a/addons/web_editor/static/src/js/editor/snippets.editor.js b/addons/web_editor/static/src/js/editor/snippets.editor.js index e320bd555cfdc5e557a6693f72420b77e64092b1..7c1d992355e8f1b4b0c04d985037fce0ec0a557e 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -1556,7 +1556,7 @@ var SnippetsMenu = Widget.extend({ // menu will take part of the screen width (delayed because of // animation). (TODO wait for real animation end) setTimeout(() => { - this.$window.trigger('resize'); + this.$window[0].dispatchEvent(new Event("resize")); }, 1000); }); }, diff --git a/addons/website/static/src/js/content/menu.js b/addons/website/static/src/js/content/menu.js index 489e6e2e198453269165324b7527e6b1f7ad3426..c72988af515f36dd536a05534f4d604a88ba6725 100644 --- a/addons/website/static/src/js/content/menu.js +++ b/addons/website/static/src/js/content/menu.js @@ -33,6 +33,10 @@ const BaseAnimatedHeader = animations.Animation.extend({ * @override */ start: function () { + // Used to prevent the editor's unbreakable protection from restoring + // the menu's auto-hide updates in edit mode. + this.el.addEventListener("autoMoreMenu.willAdapt", () => this.options.wysiwyg + && this.options.wysiwyg.odooEditor.unbreakableStepUnactive()); this.$main = this.$el.next('main'); this.isOverlayHeader = !!this.$el.closest('.o_header_overlay, .o_header_overlay_theme').length; this.$dropdowns = this.$el.find('.dropdown, .dropdown-menu');