[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) <qsm@odoo.com>
This commit is contained in:
qsm-odoo
2019-10-31 14:40:00 +00:00
committed by fw-bot
parent 837403e52c
commit ef61840e9b
@@ -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);