From 5fba47e860866e2213d6610b199883fb021a717f Mon Sep 17 00:00:00 2001 From: David Monjoie Date: Fri, 24 Feb 2023 13:08:22 +0000 Subject: [PATCH] [FIX] web_editor: no rerender when content is reset with empty string This event listener was added for the `historyStep` event of the editor in [1] as a proxy for the `input` event of the editable node. This was wrong because the `historyStep` event is also triggered at other times than when the user makes an input. In particular, it is called when switching records. In such case, the new value from props can be '' which is not suitable for edition, so it is replaced with '


'. But since that happens in a function that is going to call `_historyStep` and the editing value was just changed to something else that the value received in props, the listener from [1] would make it dirty and thus trigger a re-render etc. This commit fixes the issue by modifying the listener in such a way that it listens to the proper event it was intended to target. [1]: f56e3bca2456f04616982a9a0e77b8d4c5a0abff X-original-commit: 384ff11f06ba86360f1993cf0c8a17c2dbaa11de Part-of: odoo/odoo#113811 --- addons/web_editor/static/src/js/backend/html_field.js | 2 +- 1 file changed, 1 insertion(+), 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 729a5896fcd..573634e35a9 100644 --- a/addons/web_editor/static/src/js/backend/html_field.js +++ b/addons/web_editor/static/src/js/backend/html_field.js @@ -314,7 +314,7 @@ export class HtmlField extends Component { this.wysiwyg.toolbar.$el.append($codeviewButtonToolbar); $codeviewButtonToolbar.click(this.toggleCodeView.bind(this)); } - this.wysiwyg.odooEditor.addEventListener("historyStep", () => + this.wysiwyg.odooEditor.editable.addEventListener("input", () => this.props.setDirty(this._isDirty()) );