From f991436ee26c7c54ca4917f3506eb50867f0544a Mon Sep 17 00:00:00 2001 From: "Emilien Durieu (edu)" Date: Thu, 26 Nov 2020 14:30:24 +0000 Subject: [PATCH] [FIX] website: fix megamenu snippet editor behavior Megamenu snippet should appear in the snippet editor "block" section ONLY if a megamenu element is selected. In the current version, trying to filter snippets would make the megamenu snippet block appear. closes odoo/odoo#62414 Signed-off-by: David Monjoie (dmo) --- addons/website/static/src/js/editor/mega_menu.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/addons/website/static/src/js/editor/mega_menu.js b/addons/website/static/src/js/editor/mega_menu.js index 1665a95a5e9..a830ea2c0de 100644 --- a/addons/website/static/src/js/editor/mega_menu.js +++ b/addons/website/static/src/js/editor/mega_menu.js @@ -69,8 +69,8 @@ snippetsEditor.SnippetsMenu.include({ */ toggleMegaMenuSnippets: function (show) { setTimeout(() => this._enableLastEditor()); - - $('#snippet_mega_menu').toggleClass('d-none', !show); + this._showMegaMenuSnippets = show; + this._filterSnippets(); }, //-------------------------------------------------------------------------- @@ -87,6 +87,15 @@ snippetsEditor.SnippetsMenu.include({ $dropzone.attr('data-editor-sub-message', $hookParent.attr('data-editor-sub-message')); return $dropzone; }, -}); + /** + * @override + */ + _filterSnippets() { + this._super(...arguments); + if (!this._showMegaMenuSnippets) { + this.el.querySelector('#snippet_mega_menu').classList.add('d-none'); + } + }, +}); });