From 5a0a29b5285ea8f18716f936d58960b9b5c0f0d9 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Thu, 22 Sep 2016 13:44:06 +0200 Subject: [FIX] web_editor: prevent crash when deleting multiple snippets in one deletion Since saas-12, when deleting contents, parents are deleted too if they become empty (while it was not possible to delete contents in that case before). The problem here was that the history was recorded multiple times if one deletion made multiple snippets be deleted and this sometimes could crash. Now the history is recorded only on first deletion when the user ask for it. --- addons/web_editor/static/src/js/snippets.editor.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'addons/web_editor/static/src/js/snippets.editor.js') diff --git a/addons/web_editor/static/src/js/snippets.editor.js b/addons/web_editor/static/src/js/snippets.editor.js index 5a67b11707d..6cf2a9d33fd 100644 --- a/addons/web_editor/static/src/js/snippets.editor.js +++ b/addons/web_editor/static/src/js/snippets.editor.js @@ -1045,10 +1045,12 @@ data.Editor = Class.extend({ }, on_remove: function (event) { - event.preventDefault(); - this.on_blur(); + if (event !== undefined) { + event.preventDefault(); + this.buildingBlock.getParent().rte.historyRecordUndo(this.$target); + } - this.buildingBlock.getParent().rte.historyRecordUndo(this.$target); + this.on_blur(); var index = _.indexOf(this.buildingBlock.snippets, this.$target.get(0)); this.buildingBlock.call_for_all_snippets(this.$target, function (editor, $snippet) { @@ -1081,7 +1083,7 @@ data.Editor = Class.extend({ } if ($parent.children().length === 0 && $parent.text().trim() === "") { _.defer(function () { - $parent.data("snippet-editor").on_remove(event); + $parent.data("snippet-editor").on_remove(); }); } } -- cgit v1.2.3