[FIX] web_editor: ensure snippet selection is kept when acting in it
The snippet selection was lost on every action in mass mailing. The code that prevents that was checking if the target of a click was the body element but for mass mailing we needed to be a little bit more restrictive since the editable area is not the body itself and we want to actually prevent changing the snippet selection when the target is the iframe target as well. Since the mailing itself has a options, the sidebar is actually never empty and therefore removing a snippet doesn't bring us back to the block tab. Since therefore also ensures that we actually do. task-2716397 X-original-commit: ecdb71bf6a566f5f6c294904e84f2132561dbb3c Part-of: odoo/odoo#81662
This commit is contained in:
@@ -460,9 +460,14 @@ var SnippetEditor = Widget.extend({
|
||||
// first, destroying the related editors and not calling onBlur... to
|
||||
// check if this has always been like this or not and this should be
|
||||
// unit tested.
|
||||
const parent = this.$target[0].parentElement;
|
||||
let parent = this.$target[0].parentElement;
|
||||
const nextSibling = this.$target[0].nextElementSibling;
|
||||
const previousSibling = this.$target[0].previousElementSibling;
|
||||
if ($(parent).is('.o_editable:not(body)')) {
|
||||
// If we target the editable, we want to reset the selection to the
|
||||
// body. If the editable has options, we do not want to show them.
|
||||
parent = $(parent).closest('body');
|
||||
}
|
||||
this.trigger_up('activate_snippet', {
|
||||
$snippet: $(previousSibling || nextSibling || parent)
|
||||
});
|
||||
@@ -1293,7 +1298,7 @@ var SnippetsMenu = Widget.extend({
|
||||
if (!$target.closest('we-button, we-toggler, we-select, .o_we_color_preview').length) {
|
||||
this._closeWidgets();
|
||||
}
|
||||
if (!$target.closest('body > *').length) {
|
||||
if (!$target.closest('body > *').length || $target.is('#iframe_target')) {
|
||||
return;
|
||||
}
|
||||
if ($target.closest(this._notActivableElementsSelector).length) {
|
||||
|
||||
Reference in New Issue
Block a user