[IMP] web_responsive: Performance when hide menus

pull/1390/head
Alexandre Díaz 2019-08-08 13:11:24 +02:00
parent fd6ae6e745
commit e38a0fcf0c
1 changed files with 12 additions and 7 deletions

View File

@ -435,6 +435,8 @@ odoo.define('web_responsive', function (require) {
/** /**
* Because the menu aren't closed when click, this method * Because the menu aren't closed when click, this method
* searchs for the menu with the action executed to close it. * 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 * @param {action} action
* The executed action * The executed action
@ -442,17 +444,20 @@ odoo.define('web_responsive', function (require) {
_hideMenusByAction: function (action) { _hideMenusByAction: function (action) {
var uniq_sel = '[data-action-id='+action.id+']'; var uniq_sel = '[data-action-id='+action.id+']';
// Need close AppDrawer? // Need close AppDrawer?
$(_.str.sprintf( var menu_apps_dropdown = document.querySelector(
'.o_menu_apps .dropdown:has(.dropdown-menu.show:has(%s)) > a', '.o_menu_apps .dropdown');
uniq_sel)).dropdown('toggle'); $(menu_apps_dropdown).has('.dropdown-menu.show')
.has(uniq_sel).find('> a').dropdown('toggle');
// Need close Sections Menu? // Need close Sections Menu?
// TODO: Change to 'hide' in modern Bootstrap >4.1 // TODO: Change to 'hide' in modern Bootstrap >4.1
$(_.str.sprintf( var menu_sections = document.querySelector(
'.o_menu_sections li.show:has(%s) .dropdown-toggle', uniq_sel)) '.o_menu_sections li.show');
$(menu_sections).has(uniq_sel).find('.dropdown-toggle')
.dropdown('toggle'); .dropdown('toggle');
// Need close Mobile? // Need close Mobile?
$(_.str.sprintf('.o_menu_sections.show:has(%s)', uniq_sel)) var menu_sections_mobile = document.querySelector(
.collapse('hide'); '.o_menu_sections.show');
$(menu_sections_mobile).has(uniq_sel).collapse('hide');
}, },
_handleAction: function (action) { _handleAction: function (action) {