From ca215a5bdf20a1a665cfa87fb4fab0d9b3a0ae2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Souk=C3=A9ina=20Bojabza?= Date: Fri, 2 Sep 2022 17:39:17 +0000 Subject: [PATCH] [IMP] web_editor: update UI when clicking on mobile preview Now trigger an UI update for all the options when clicking on the mobile preview button. This is at least important for the next commit in this PR to update the visibility of the different overlay elements as some will be shown in desktop and some other on mobile. task-2825241 Part-of: odoo/odoo#93144 Co-authored-by: qsm-odoo --- .../static/src/js/editor/snippets.editor.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/addons/web_editor/static/src/js/editor/snippets.editor.js b/addons/web_editor/static/src/js/editor/snippets.editor.js index 798bb32d024..e01db7a1f38 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -3526,8 +3526,24 @@ var SnippetsMenu = Widget.extend({ /** * Preview on mobile. */ - _onMobilePreviewClick: function () { + _onMobilePreviewClick() { this.trigger_up('request_mobile_preview'); + + // TODO refactor things to make this more understandable -> on mobile + // edition, update the UI. But to do it properly and inside the mutex + // this simulates what happens when a snippet option is used. + this._execWithLoadingEffect(async () => { + // TODO needed so that mobile edition is considered before updating + // the UI but this is clearly random. The trigger_up above should + // properly await for the rerender somehow. + await new Promise(resolve => setTimeout(resolve)); + + return new Promise(resolve => { + this.trigger_up('snippet_option_update', { + onSuccess: () => resolve(), + }); + }); + }, false); }, /** * Undo..