summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web_editor/static/src')
-rw-r--r--addons/web_editor/static/src/js/editor/snippets.editor.js18
1 files changed, 12 insertions, 6 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 258c6d46041..ccdfc8ddec5 100644
--- a/addons/web_editor/static/src/js/editor/snippets.editor.js
+++ b/addons/web_editor/static/src/js/editor/snippets.editor.js
@@ -206,17 +206,17 @@ var SnippetEditor = Widget.extend({
}
if ($parent.closest(':data("snippet-editor")').length) {
- while (!$parent.data('snippet-editor')) {
+ var editor = $parent.data('snippet-editor');
+ while (!editor) {
var $nextParent = $parent.parent();
- if ($parent.children().length === 0 && $parent.text().trim() === '' && !$parent.hasClass('oe_structure')) {
+ if (isEmptyAndRemovable($parent)) {
$parent.remove();
}
$parent = $nextParent;
+ editor = $parent.data('snippet-editor');
}
- if ($parent.children().length === 0 && $parent.text().trim() === '' && !$parent.hasClass('oe_structure')) {
- _.defer(function () {
- $parent.data('snippet-editor').removeSnippet();
- });
+ if (isEmptyAndRemovable($parent, editor)) {
+ setTimeout(() => editor.removeSnippet());
}
}
@@ -227,6 +227,12 @@ var SnippetEditor = Widget.extend({
this.trigger_up('snippet_removed');
this.destroy();
$parent.trigger('content_changed');
+
+ function isEmptyAndRemovable($el, editor) {
+ editor = editor || $el.data('snippet-editor');
+ return $el.children().length === 0 && $el.text().trim() === ''
+ && !$el.hasClass('oe_structure') && (!editor || editor.isTargetParentEditable);
+ }
},
/**
* Displays/Hides the editor overlay and notifies the associated snippet