From 02f845ea689f6c48fb490fd23d2f4bb2a7a5877a Mon Sep 17 00:00:00 2001 From: Younn Olivier Date: Thu, 5 Aug 2021 08:06:39 +0000 Subject: [PATCH] [FIX] web_editor: only send observerApply event when needed REASON FOR THE FIX To correctly display the overlay over a rotated element, we need to reset the transform of the element, to be able to apply it on the overlay. Changing the style of the element in the SnippetEditor cover method would trigger a DOM mutation, which will result in setting the odooEditor observer unactive. The issue was that flushing the observer (when setting it unactive) would always send an event observerApply, even if no record was processed. It was an issue as the SnippetsMenu was triggering a content_changed event at the reception of this event, which would rerender the SnippetEditor overlay cover (and create an infinite loop of events). SOLUTION To avoid that, the observerApply event is sent only if records were processed. Part of https://github.com/odoo/odoo/pull/74592 task-2554608 --- addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 8ca902e67f9..4842d935a21 100644 --- a/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js +++ b/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js @@ -467,7 +467,9 @@ export class OdooEditor extends EventTarget { } } } - this.dispatchEvent(new Event('observerApply')); + if (records.length) { + this.dispatchEvent(new Event('observerApply')); + } } filterMutationRecords(records) { // Save the first attribute in a cache to compare only the first