[FIX] web_responsive: modify action handling

Previous this commit, AppMenu doesn't hide in some situations.
Steps to reproduce (sometimes works, sometimes doesn't):
From Discuss App (refresh) open AppMenu and search some menu,
select the second in the list and press enter.
The action is launched correctly, but the AppMenu doesn't hide.

Now uses 'defer' to ensure that all has done to do the task
This commit is contained in:
Alexandre Díaz
2019-11-20 17:36:48 +01:00
parent 0309122e00
commit 1325b260c8

View File

@@ -442,22 +442,24 @@ odoo.define('web_responsive', function (require) {
* The executed action
*/
_hideMenusByAction: function (action) {
var uniq_sel = '[data-action-id='+action.id+']';
// Need close AppDrawer?
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
var menu_sections = document.querySelector(
'.o_menu_sections li.show');
$(menu_sections).has(uniq_sel).find('.dropdown-toggle')
.dropdown('toggle');
// Need close Mobile?
var menu_sections_mobile = document.querySelector(
'.o_menu_sections.show');
$(menu_sections_mobile).has(uniq_sel).collapse('hide');
_.defer(function () {
var uniq_sel = '[data-action-id='+action.id+']';
// Need close AppDrawer?
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
var menu_sections = document.querySelector(
'.o_menu_sections li.show');
$(menu_sections).has(uniq_sel).find('.dropdown-toggle')
.dropdown('toggle');
// Need close Mobile?
var menu_sections_mobile = document.querySelector(
'.o_menu_sections.show');
$(menu_sections_mobile).has(uniq_sel).collapse('hide');
});
},
_handleAction: function (action) {