diff options
| author | qsm-odoo <qsm@odoo.com> | 2016-09-22 13:44:06 +0200 |
|---|---|---|
| committer | qsm-odoo <qsm@odoo.com> | 2016-09-22 13:44:06 +0200 |
| commit | 5a0a29b5285ea8f18716f936d58960b9b5c0f0d9 (patch) | |
| tree | 1440b8758d439a1fd991af868406240f1c2bf409 /addons/web_editor/static/src/js/snippets.editor.js | |
| parent | 6dc985b0add0af59fd98f7cc6437600dede11d72 (diff) | |
[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.
Diffstat (limited to 'addons/web_editor/static/src/js/snippets.editor.js')
| -rw-r--r-- | addons/web_editor/static/src/js/snippets.editor.js | 10 |
1 files changed, 6 insertions, 4 deletions
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(); }); } } |
