From 77178fe5aef1d39d4131d9fca1970b8bbccd97e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Geelen=20=28sge=29?= Date: Thu, 21 Apr 2022 08:50:04 +0000 Subject: [PATCH] [FIX] web_editor: fix onChange event MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ensure the `onChange()` callback is called after each history steps in the editor. Call the `_doAction()` directly, to avoid using the disabled `_doDebouncedAction()`. task-2760436 closes odoo/odoo#89339 X-original-commit: 18eaabcb4dab4682e3a94e16dbe66ff3c6f35a77 Signed-off-by: David Monjoie (dmo) Signed-off-by: Geelen Sébastien (sge) --- addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js | 2 +- addons/web_editor/static/src/js/backend/field_html.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js b/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js index 61fec6bc220..a05b18988cd 100644 --- a/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js +++ b/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js @@ -489,7 +489,6 @@ export class OdooEditor extends EventTarget { this.observer = new MutationObserver(records => { records = this.filterMutationRecords(records); if (!records.length) return; - this.dispatchEvent(new Event('contentChanged')); clearTimeout(this.observerTimeout); if (this._observerTimeoutUnactive.size === 0) { this.observerTimeout = setTimeout(() => { @@ -722,6 +721,7 @@ export class OdooEditor extends EventTarget { this._checkStepUnbreakable = true; this._recordHistorySelection(); this.dispatchEvent(new Event('historyStep')); + this.dispatchEvent(new Event('contentChanged')); this.multiselectionRefresh(); } // apply changes according to some records diff --git a/addons/web_editor/static/src/js/backend/field_html.js b/addons/web_editor/static/src/js/backend/field_html.js index f5cf305a839..9388a401bee 100644 --- a/addons/web_editor/static/src/js/backend/field_html.js +++ b/addons/web_editor/static/src/js/backend/field_html.js @@ -465,7 +465,7 @@ var FieldHtml = basic_fields.DebouncedField.extend(TranslatableFieldMixin, { * @param {OdooEvent} ev */ _onChange: function (ev) { - this._doDebouncedAction.apply(this, arguments); + this._doAction(); }, /** * Allows Enter keypress in a textarea (source mode)