Skip to content

Commit

Permalink
[FIX] web_editor: convert inline before send message
Browse files Browse the repository at this point in the history
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]: 3573167

opw-3885368

X-original-commit: b7ecc3f
  • Loading branch information
Mtaylorr committed May 13, 2024
1 parent 8d61cde commit 4f076cb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions addons/web_editor/static/src/js/backend/html_field.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit 4f076cb

Please sign in to comment.