From ef61840e9b51ada752ff6d53939897ba25240684 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Thu, 31 Oct 2019 11:44:33 +0000 Subject: [PATCH] [FIX] web_editor: onBlur was sometimes not called when it should have There recently were some fixes to the system of onFocus/onBlur with the new left panel of the 13.0 editor and one still remained: the onBlur method was most of the time called only on the main snippet options and not the child ones. Now it works as it should, even if the system logic has to be improved to be more robust. One difference remains with 12.0 but this can be considered as a change for the 13.0 version: the parent options onFocus/onBlur are called before the child options while it was the opposite before. closes odoo/odoo#39659 X-original-commit: 502db91c0b38567dede5d683370fef82890a99f0 Signed-off-by: Quentin Smetz (qsm) --- addons/web_editor/static/src/js/editor/snippets.editor.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/web_editor/static/src/js/editor/snippets.editor.js b/addons/web_editor/static/src/js/editor/snippets.editor.js index c3748869d1c..7140efe4699 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -1053,16 +1053,17 @@ var SnippetsMenu = Widget.extend({ resolve(null); }).then(editorToEnable => { // First disable all editors... - this.snippetEditors.forEach(editor => { + for (let i = this.snippetEditors.length; i--;) { + const editor = this.snippetEditors[i]; if (editor === editorToEnable) { // Avoid disable -> enable of an editor (the toggleFocus // method is in charge of doing nothing is nothing has // to be done but if we explicitly ask for disable then // enable... it will disable then enable). - return; + continue; } editor.toggleFocus(false, previewMode); - }); + } // ... then enable the right editor if (editorToEnable) { editorToEnable.toggleFocus(true, previewMode);