[FIX] web_editor: better urgent save for to inline html field
Reorganize the urgent save steps to call `_toInline` before the urgent `updateValue`. This will give a chance to the _toInline to finish before the `updateValue` if no asynchronous process is triggered during the inlining process. In case we have some async stuff that delay the `_toInline` completion, we keep the second `updateValue` which will wait for the asynchronous completion, as before. task-3222474 X-original-commit: 85540a58a58b5f60b587697490fe837b3e4a69ec Part-of: odoo/odoo#124020
This commit is contained in:
@@ -397,15 +397,21 @@ export class HtmlField extends Component {
|
||||
}
|
||||
async commitChanges({ urgent } = {}) {
|
||||
if (this._isDirty() || urgent) {
|
||||
let toInlinePromise;
|
||||
if (this.wysiwyg) {
|
||||
this.wysiwyg.odooEditor.observerUnactive('commitChanges');
|
||||
await this.wysiwyg.savePendingImages();
|
||||
if (this.props.isInlineStyle) {
|
||||
// Avoid listening to changes made during the _toInline process.
|
||||
toInlinePromise = this._toInline();
|
||||
}
|
||||
}
|
||||
if (urgent) {
|
||||
await this.updateValue();
|
||||
}
|
||||
if (this.wysiwyg) {
|
||||
// Avoid listening to changes made during the _toInline process.
|
||||
this.wysiwyg.odooEditor.observerUnactive('commitChanges');
|
||||
await this.wysiwyg.savePendingImages();
|
||||
if (this.props.isInlineStyle) {
|
||||
await this._toInline();
|
||||
await toInlinePromise;
|
||||
}
|
||||
this.wysiwyg.odooEditor.observerActive('commitChanges');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user