[FIX] web_editor: commit changes when using the sidebar
Before this commit, some operation (eg. move node, duplicate or remove a snippet from the snippetMenu) in the snippetMenu sidebar did not trigger the mass mailing commit changes and therefore if no selection was made in the document followed by a blur was made, no changes could be recorded and saved by the owl form component. task-3052658 X-original-commit: 8bd8db97ee0d7774e5aa0495b9a5cc7d695fca67 Part-of: odoo/odoo#112908
This commit is contained in:
@@ -17,7 +17,6 @@ import { getRangePosition } from '@web_editor/js/editor/odoo-editor/src/utils/ut
|
||||
|
||||
const {
|
||||
onWillStart,
|
||||
useEffect,
|
||||
useSubEnv,
|
||||
onWillUpdateProps,
|
||||
} = owl;
|
||||
@@ -41,15 +40,6 @@ export class MassMailingHtmlField extends HtmlField {
|
||||
this._hideIrrelevantTemplates();
|
||||
}
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const listener = () => {
|
||||
this._lastClickInIframe = false;
|
||||
};
|
||||
document.addEventListener('mousedown', listener, true);
|
||||
|
||||
return () => document.removeEventListener('mousedown', listener, true);
|
||||
}, () => []);
|
||||
}
|
||||
|
||||
get wysiwygOptions() {
|
||||
@@ -173,10 +163,6 @@ export class MassMailingHtmlField extends HtmlField {
|
||||
this.wysiwyg.odooEditor.historyReset();
|
||||
this.wysiwyg.$iframeBody.addClass('o_mass_mailing_iframe');
|
||||
|
||||
this.wysiwyg.odooEditor.document.addEventListener('mousedown', () => {
|
||||
this._lastClickInIframe = true;
|
||||
}, true);
|
||||
|
||||
this.onIframeUpdated();
|
||||
}
|
||||
|
||||
@@ -589,11 +575,6 @@ export class MassMailingHtmlField extends HtmlField {
|
||||
async _getWysiwygClass() {
|
||||
return getWysiwygClass({moduleName: 'mass_mailing.wysiwyg'});
|
||||
}
|
||||
_onWysiwygBlur() {
|
||||
if (!this._lastClickInIframe) {
|
||||
super._onWysiwygBlur();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MassMailingHtmlField.props = {
|
||||
|
||||
@@ -130,7 +130,7 @@ const Wysiwyg = Widget.extend({
|
||||
this.$editable.data('oe-model', options.recordInfo.res_model);
|
||||
this.$editable.data('oe-id', options.recordInfo.res_id);
|
||||
document.addEventListener('mousedown', this._onDocumentMousedown, true);
|
||||
this.$editable.on('blur', this._onBlur);
|
||||
this._bindOnBlur();
|
||||
|
||||
this.toolbar = new Toolbar(this, this.options.toolbarTemplate);
|
||||
await this.toolbar.appendTo(document.createElement('void'));
|
||||
@@ -2632,6 +2632,9 @@ const Wysiwyg = Widget.extend({
|
||||
}
|
||||
}
|
||||
},
|
||||
_bindOnBlur() {
|
||||
this.$editable.on('blur', this._onBlur);
|
||||
},
|
||||
|
||||
});
|
||||
Wysiwyg.activeCollaborationChannelNames = new Set();
|
||||
|
||||
@@ -174,6 +174,20 @@ Wysiwyg.include({
|
||||
return this._super.apply(this, arguments);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Bind the blur event on the iframe so that it would not blur when using
|
||||
* the sidebar.
|
||||
*
|
||||
* @override
|
||||
*/
|
||||
_bindOnBlur: function () {
|
||||
if (!this.options.inIframe) {
|
||||
this._super.apply(this, arguments);
|
||||
} else {
|
||||
this.$iframe[0].contentWindow.addEventListener('blur', this._onBlur);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user