diff --git a/web_responsive/static/src/js/web_responsive.js b/web_responsive/static/src/js/web_responsive.js index 2b8656da0..0d9bfa793 100644 --- a/web_responsive/static/src/js/web_responsive.js +++ b/web_responsive/static/src/js/web_responsive.js @@ -435,6 +435,8 @@ odoo.define('web_responsive', function (require) { /** * Because the menu aren't closed when click, this method * searchs for the menu with the action executed to close it. + * To avoid delays in pages with a lot of DOM nodes we make + * 'sub-groups' with 'querySelector' to improve the performance. * * @param {action} action * The executed action @@ -442,17 +444,20 @@ odoo.define('web_responsive', function (require) { _hideMenusByAction: function (action) { var uniq_sel = '[data-action-id='+action.id+']'; // Need close AppDrawer? - $(_.str.sprintf( - '.o_menu_apps .dropdown:has(.dropdown-menu.show:has(%s)) > a', - uniq_sel)).dropdown('toggle'); + var menu_apps_dropdown = document.querySelector( + '.o_menu_apps .dropdown'); + $(menu_apps_dropdown).has('.dropdown-menu.show') + .has(uniq_sel).find('> a').dropdown('toggle'); // Need close Sections Menu? // TODO: Change to 'hide' in modern Bootstrap >4.1 - $(_.str.sprintf( - '.o_menu_sections li.show:has(%s) .dropdown-toggle', uniq_sel)) + var menu_sections = document.querySelector( + '.o_menu_sections li.show'); + $(menu_sections).has(uniq_sel).find('.dropdown-toggle') .dropdown('toggle'); // Need close Mobile? - $(_.str.sprintf('.o_menu_sections.show:has(%s)', uniq_sel)) - .collapse('hide'); + var menu_sections_mobile = document.querySelector( + '.o_menu_sections.show'); + $(menu_sections_mobile).has(uniq_sel).collapse('hide'); }, _handleAction: function (action) {