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 6886b466348..4802934cb43 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -316,7 +316,13 @@ var SnippetEditor = Widget.extend({ }); }); - this.trigger_up('go_to_parent', {$snippet: this.$target}); + const parent = this.$target[0].parentElement; + const nextSibling = this.$target[0].nextElementSibling; + const previousSibling = this.$target[0].previousElementSibling; + this.trigger_up('activate_snippet', { + $snippet: $(previousSibling || nextSibling || parent) + }); + var $parent = this.$target.parent(); this.$target.find('*').addBack().tooltip('dispose'); this.$target.remove(); @@ -658,7 +664,7 @@ var SnippetEditor = Widget.extend({ } } - this.trigger_up('go_to_parent', {$snippet: this.$target}); + this.trigger_up('activate_snippet', {$snippet: this.$target.parent()}); this.trigger_up('activate_insertion_zones', { $selectorSiblings: $selectorSiblings, $selectorChildren: $selectorChildren, @@ -921,7 +927,6 @@ var SnippetsMenu = Widget.extend({ 'deactivate_snippet': '_onDeactivateSnippet', 'drag_and_drop_stop': '_onDragAndDropStop', 'get_snippet_versions': '_onGetSnippetVersions', - 'go_to_parent': '_onGoToParent', 'remove_snippet': '_onRemoveSnippet', 'snippet_edition_request': '_onSnippetEditionRequest', 'snippet_editor_destroyed': '_onSnippetEditorDestroyed', @@ -2333,17 +2338,6 @@ var SnippetsMenu = Widget.extend({ await this._destroyEditors($modal.length ? $modal : null); await this._activateSnippet(ev.data.$snippet); }, - /** - * Called when a snippet editor asked to disable itself and to enable its - * parent instead. - * - * @private - * @param {OdooEvent} ev - */ - _onGoToParent: function (ev) { - ev.stopPropagation(); - this._activateSnippet(ev.data.$snippet.parent()); - }, /** * @private */