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 25964dc0665..e5740bd2550 100644 --- a/addons/web_editor/static/src/js/backend/html_field.js +++ b/addons/web_editor/static/src/js/backend/html_field.js @@ -51,11 +51,17 @@ export class HtmlFieldWysiwygAdapterComponent extends ComponentAdapter { updateWidget(newProps) { const lastValue = String(this.props.widgetArgs[0].value || ''); + const lastRecordInfo = this.props.widgetArgs[0].recordInfo; const lastCollaborationChannel = this.props.widgetArgs[0].collaborationChannel; const newValue = String(newProps.widgetArgs[0].value || ''); + const newRecordInfo = newProps.widgetArgs[0].recordInfo; const newCollaborationChannel = newProps.widgetArgs[0].collaborationChannel; - if ((newValue !== newProps.editingValue && lastValue !== newValue) || !_.isEqual(lastCollaborationChannel, newCollaborationChannel)) { + if ( + (newValue !== newProps.editingValue && lastValue !== newValue) || + !_.isEqual(lastRecordInfo, newRecordInfo) || + !_.isEqual(lastCollaborationChannel, newCollaborationChannel)) + { this.widget.resetEditor(newValue, { collaborationChannel: newCollaborationChannel, }); @@ -99,13 +105,23 @@ export class HtmlField extends Component { this.cssEditAsset = await ajax.loadAsset(this.props.cssEditAssetId || 'web_editor.assets_edit_html_field'); } }); + this._lastRecordInfo = { + res_model: this.props.record.resModel, + res_id: this.props.record.resId, + }; onWillUpdateProps((newProps) => { if (!newProps.readonly && this.state.iframeVisible) { this.state.iframeVisible = false; } - if (!this._selfUpdating) { + + const newRecordInfo = { + res_model: this.props.record.resModel, + res_id: this.props.record.resId, + }; + if (!_.isEqual(this._lastRecordInfo, newRecordInfo)) { this.currentEditingValue = undefined; } + this._lastRecordInfo = newRecordInfo; }); useEffect(() => { (async () => { @@ -266,9 +282,7 @@ export class HtmlField extends Component { this.props.setDirty(true); } this.currentEditingValue = value; - this._selfUpdating = true; await this.props.update(value); - this._selfUpdating = false; } } async startWysiwyg(wysiwyg) {