diff --git a/addons/web/static/lib/bootstrap/js/dist/dropdown.js b/addons/web/static/lib/bootstrap/js/dist/dropdown.js index d0b872d5dc5..f8799b92ae1 100644 --- a/addons/web/static/lib/bootstrap/js/dist/dropdown.js +++ b/addons/web/static/lib/bootstrap/js/dist/dropdown.js @@ -257,6 +257,7 @@ const CLASS_NAME_NAVBAR = 'navbar'; const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="dropdown"]'; const SELECTOR_MENU = '.dropdown-menu:not(.o-dropdown--menu)'; + const SELECTOR_MENU_NOT_SUB = '.dropdown-menu:not(.o-dropdown--menu):not(.o_wysiwyg_submenu)'; const SELECTOR_NAVBAR_NAV = '.navbar-nav'; const SELECTOR_VISIBLE_ITEMS = '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)'; const PLACEMENT_TOP = isRTL() ? 'top-end' : 'top-start'; @@ -665,7 +666,7 @@ EventHandler__default.default.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE, Dropdown.dataApiKeydownHandler); - EventHandler__default.default.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown.dataApiKeydownHandler); + EventHandler__default.default.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_MENU_NOT_SUB, Dropdown.dataApiKeydownHandler); EventHandler__default.default.on(document, EVENT_CLICK_DATA_API, Dropdown.clearMenus); EventHandler__default.default.on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus); EventHandler__default.default.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) { diff --git a/addons/website/static/src/components/wysiwyg_adapter/wysiwyg_adapter.js b/addons/website/static/src/components/wysiwyg_adapter/wysiwyg_adapter.js index 9e2597fe8b2..dc27b31ef6a 100644 --- a/addons/website/static/src/components/wysiwyg_adapter/wysiwyg_adapter.js +++ b/addons/website/static/src/components/wysiwyg_adapter/wysiwyg_adapter.js @@ -168,6 +168,8 @@ export class WysiwygAdapterComponent extends Wysiwyg { // Dropdown menu initialization: handle dropdown openings by hand var $dropdownMenuToggles = $editableWindow.$('.o_mega_menu_toggle, #o_main_nav .dropdown-toggle'); $dropdownMenuToggles.removeAttr('data-bs-toggle').dropdown('dispose'); + // Since bootstrap 5.1.3, removing bsToggle is not sufficient anymore. + $dropdownMenuToggles.siblings(".dropdown-menu").addClass("o_wysiwyg_submenu"); $dropdownMenuToggles.on('click.wysiwyg_megamenu', ev => { this.odooEditor.observerUnactive(); var $toggle = $(ev.currentTarget); @@ -935,7 +937,7 @@ export class WysiwygAdapterComponent extends Wysiwyg { // FIXME normally removing the 'show' class should not be necessary here // TODO check that editor classes are removed here as well const classes = [...$el[0].classList].filter(megaMenuClass => - ["dropdown-menu", "o_mega_menu", "show"].indexOf(megaMenuClass) < 0); + ["dropdown-menu", "o_mega_menu", "show", "o_wysiwyg_submenu"].indexOf(megaMenuClass) < 0); promises.push( this.orm.write('website.menu', [parseInt($el.data('oe-id'))], { 'mega_menu_classes': classes.join(' '), diff --git a/addons/website/static/tests/tours/edit_megamenu.js b/addons/website/static/tests/tours/edit_megamenu.js index 30b18d7b533..91f0716637c 100644 --- a/addons/website/static/tests/tours/edit_megamenu.js +++ b/addons/website/static/tests/tours/edit_megamenu.js @@ -85,6 +85,14 @@ wTourUtils.registerWebsitePreviewTour('edit_megamenu', { allowInvisible: true, run: 'text New Menu Item', }, + { + // If this step fails, it means that a patch inside bootstrap was lost. + content: "Press the 'down arrow' key.", + trigger: 'iframe .o_mega_menu h4', + run: function (actions) { + this.$anchor[0].dispatchEvent(new window.KeyboardEvent("keydown", { key: "ArrowDown" })); + }, + }, ...wTourUtils.clickOnSave(), wTourUtils.clickOnExtraMenuItem({}, true), toggleMegaMenu(), diff --git a/addons/website/static/tests/tours/edit_menus.js b/addons/website/static/tests/tours/edit_menus.js index 9d5feb49ce6..101c8e39d69 100644 --- a/addons/website/static/tests/tours/edit_menus.js +++ b/addons/website/static/tests/tours/edit_menus.js @@ -274,5 +274,18 @@ wTourUtils.registerWebsitePreviewTour('edit_menus', { trigger: 'iframe #top_menu .nav-item:has(a.o_mega_menu_toggle:contains("Megaaaaa!")) ' + '.s_mega_menu_odoo_menu', run: () => {}, // It's a check. - } + }, + ...wTourUtils.clickOnEditAndWaitEditMode(), + { + content: "Open nested menu item", + trigger: 'iframe #top_menu .nav-item:contains("Home"):nth(1) .dropdown-toggle', + }, + { + // If this step fails, it means that a patch inside bootstrap was lost. + content: "Press the 'down arrow' key.", + trigger: 'iframe #top_menu .nav-item:contains("Home") li:contains("Contact us")', + run: function (actions) { + this.$anchor[0].dispatchEvent(new window.KeyboardEvent("keydown", { key: "ArrowDown" })); + }, + }, ]);