From b7d1db596bf2dcbf5d95d7258d9a2978bc0003f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Lef=C3=A8vre?= Date: Fri, 28 Feb 2020 11:25:41 +0000 Subject: [FIX] web: Call on_attach_callback on systray widgets Currently, the method `on_attach_callback` is never called on any Widget in the systray. Calling `on_attach_callback` is required if any systray widget uses an OWL component via the ComponentWrapper. Without the callback, the component is never considered mounted to the DOM and no event handler is triggered. closes odoo/odoo#46566 Related: odoo/enterprise#8887 Signed-off-by: Aaron Bohy (aab) --- addons/web/static/src/js/chrome/menu.js | 1 + addons/web/static/src/js/chrome/systray_menu.js | 5 +++++ 2 files changed, 6 insertions(+) (limited to 'addons/web/static/src/js') diff --git a/addons/web/static/src/js/chrome/menu.js b/addons/web/static/src/js/chrome/menu.js index 6f2815b670a..3c3530d49e9 100644 --- a/addons/web/static/src/js/chrome/menu.js +++ b/addons/web/static/src/js/chrome/menu.js @@ -69,6 +69,7 @@ var Menu = Widget.extend({ // Systray Menu this.systray_menu = new SystrayMenu(this); var systrayMenuProm = this.systray_menu.attachTo(this.$('.o_menu_systray')).then(function() { + self.systray_menu.on_attach_callback(); // At this point, we know we are in the DOM dom.initAutoMoreMenu(self.$section_placeholder, { maxWidth: function () { return self.$el.width() - (self.$menu_apps.outerWidth(true) + self.$menu_brand_placeholder.outerWidth(true) + self.systray_menu.$el.outerWidth(true)); diff --git a/addons/web/static/src/js/chrome/systray_menu.js b/addons/web/static/src/js/chrome/systray_menu.js index cb292a9b90f..0e25f2566de 100644 --- a/addons/web/static/src/js/chrome/systray_menu.js +++ b/addons/web/static/src/js/chrome/systray_menu.js @@ -39,6 +39,11 @@ var SystrayMenu = Widget.extend({ return Promise.all(proms); }); }, + on_attach_callback() { + this.widgets + .filter(widget => widget.on_attach_callback) + .forEach(widget => widget.on_attach_callback()); + }, /** * Add the instanciated items, using the object located in this.wisgets */ -- cgit v1.2.3