From b63a0dced3d07a8e56831c47edcc3c401e4a3fdb Mon Sep 17 00:00:00 2001 From: Nicolas Bayet Date: Wed, 18 Jan 2023 10:35:45 +0000 Subject: [PATCH] [FIX] web_editor: save the content without blur When the only change in a form was made in the html editor, if the user did not blur the editor, the content was not saved. The reason is because the `urgentSave` in `basic_relational_model.js` check if the record is dirty before the HtmlField had the time to update the value to make it dirty since the commitChange in the HtmlField could run promises before calling `update`. To solve it, in case of urgent save, we update the value before any asynchronous modification and re-update it after those modifications. In order to have this strategy only on urgentSave and not on the blur of the editor, the params `{urgent: true}` has been removed in `_onWysiwygBlur` as it seems to not be useful. Another params will need to be added if we want to keep that behavior on blur. task-3140763 closes odoo/odoo#110517 X-original-commit: 3ff0d4b032e44719f52d09c7bfb701c47a79a5c3 Signed-off-by: David Monjoie (dmo) --- addons/web_editor/static/src/js/backend/html_field.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 7e65288e29f..6fe06a56b7a 100644 --- a/addons/web_editor/static/src/js/backend/html_field.js +++ b/addons/web_editor/static/src/js/backend/html_field.js @@ -354,6 +354,9 @@ export class HtmlField extends Component { } async commitChanges({ urgent } = {}) { if (this._isDirty() || urgent) { + if (urgent) { + await this.updateValue(); + } if (this.wysiwyg) { // Avoid listening to changes made during the _toInline process. this.wysiwyg.odooEditor.observerUnactive('commitChanges'); @@ -532,7 +535,7 @@ export class HtmlField extends Component { }])); } _onWysiwygBlur() { - this.commitChanges({ urgent: true }); + this.commitChanges(); } async _onReadonlyClickChecklist(ev) { if (ev.offsetX > 0) {