[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) <dmo@odoo.com>
This commit is contained in:
Nicolas Bayet
2023-01-20 17:52:14 +01:00
parent 15201b1e28
commit b63a0dced3
@@ -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) {