From eb5e5258a43cb5490d6e701464ed0cbe282d62ad Mon Sep 17 00:00:00 2001 From: "Arthur Detroux (ard)" Date: Thu, 7 Jul 2022 14:07:19 +0000 Subject: [PATCH] [FIX] website: await async part when changing transparent header color Commit [1] adapted the topMenuColor option to the 14.0 editor but did not await the call to action_demand. This didn't cause any issue but could lead to race conditions and is not correct. It also breaks after [2]. [1]: https://github.com/odoo/odoo/commit/98c8438f5225dbc34b15fc2ed5b9918d537bb71b [2]: https://github.com/odoo/odoo/commit/31cc10b91dc7762e23b4bde9b945be0c4ce3fe3b task-2687506 closes odoo/odoo#96059 X-original-commit: a22afd698e7c04d302a1c90888b015413dd8c930 Signed-off-by: Quentin Smetz (qsm) Signed-off-by: Arthur Detroux (ard) --- .../static/src/js/editor/snippets.options.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/addons/website/static/src/js/editor/snippets.options.js b/addons/website/static/src/js/editor/snippets.options.js index bd719db44f4..32e9da6d72f 100644 --- a/addons/website/static/src/js/editor/snippets.options.js +++ b/addons/website/static/src/js/editor/snippets.options.js @@ -2239,12 +2239,16 @@ options.registry.topMenuColor = options.Class.extend({ /** * @override */ - selectStyle(previewMode, widgetValue, params) { - this._super(...arguments); + async selectStyle(previewMode, widgetValue, params) { + await this._super(...arguments); const className = widgetValue ? (params.colorPrefix + widgetValue) : ''; - this.trigger_up('action_demand', { - actionName: 'toggle_page_option', - params: [{name: 'header_color', value: className}], + await new Promise((resolve, reject) => { + this.trigger_up('action_demand', { + actionName: 'toggle_page_option', + params: [{name: 'header_color', value: className}], + onSuccess: resolve, + onFailure: reject, + }); }); },