From 4f076cb16363efce672a3adfe408a6a713eae13d Mon Sep 17 00:00:00 2001 From: "Mahdi Cheikh Rouhou (macr)" Date: Thu, 25 Apr 2024 11:17:49 +0000 Subject: [PATCH] [FIX] web_editor: convert inline before send message Commit that introduced the issue: [1] Issue: ====== The email sent from chatter message isn't correctly formatted. Steps to reproduce the issue: ============================= - Go to chatter of any form view - Open the mail compose modal - Add a primary link the in the email body - Send it - The email isn't formatted in the received email. Origin of the issue: ==================== The flow goes as follow, we first change the field and then when clicking send, we first update the value of the editor by `onWysiwygBlur` , then before the send is done, the field is saved which will trigger the event `NEED_LOCAL_CHANGES` which will call commitChanges, but since we already updated the value and we don't have urgent, nothing will happend and the function `toInline` will never be called. Solution: ========= To not break the old commit behavior and make it reset with disard, we add another flag `shouldInline` so we can force `commitChanges` and calculating inline style when saving. [1]: https://github.com/odoo/odoo/commit/35731674561efa391852fd7e42a19c732c29886f opw-3885368 X-original-commit: b7ecc3f36e8d238dac727c8341c51c3b283605fe --- addons/web_editor/static/src/js/backend/html_field.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/web_editor/static/src/js/backend/html_field.js b/addons/web_editor/static/src/js/backend/html_field.js index 8d0134689e037..75785d52579b8 100644 --- a/addons/web_editor/static/src/js/backend/html_field.js +++ b/addons/web_editor/static/src/js/backend/html_field.js @@ -100,7 +100,7 @@ export class HtmlField extends Component { this.commitChanges({ urgent: true }) ); useBus(model.bus, "NEED_LOCAL_CHANGES", ({ detail }) => - detail.proms.push(this.commitChanges()) + detail.proms.push(this.commitChanges({ shouldInline: true })) ); useSpellCheck(); @@ -403,8 +403,8 @@ export class HtmlField extends Component { popover.style.top = topPosition + 'px'; popover.style.left = leftPosition + 'px'; } - async commitChanges({ urgent } = {}) { - if (this._isDirty() || urgent) { + async commitChanges({ urgent, shouldInline } = {}) { + if (this._isDirty() || urgent || (shouldInline && this.props.isInlineStyle)) { let savePendingImagesPromise, toInlinePromise; if (this.wysiwyg && this.wysiwyg.odooEditor) { this.wysiwyg.odooEditor.observerUnactive('commitChanges');