From ac170e8a8238a9b0aa468f83b11aabc4cd9493de Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Fri, 19 Jul 2019 14:50:15 +0000 Subject: [FIX] web_editor, website: stop snippet animations before cloning Before this commit, when a snippet was cloned, its animation was not destroyed first. The flow was: 1. Clone the snippet (DOM) - web_editor trigger `snippet_cloned` 2. Start cloned snippet animation - website listen `snippet_cloned` This was causing bugs, eg facebook snippet for which the animation is to create an iframe containing the facebook widget. When cloning this snippet, its iframe would be cloned to, then its animation would be started, creating another iframe. To fix such flows, the snippet cloning flow should be: 1. Strop the snippet animation 2. Clone the snippet (DOM) - web_editor trigger `snippet_cloned` 3. Start cloned snippet animation - website listen `snippet_cloned` 4. Restart the original snippet animation task-1951466 closes odoo/odoo#35029 Signed-off-by: Quentin Smetz (qsm) --- addons/web_editor/static/src/js/editor/snippets.editor.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'addons/web_editor/static/src') 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 11a96897fa6..803a190256f 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -337,6 +337,9 @@ var SnippetEditor = Widget.extend({ */ _onCloneClick: function (ev) { ev.preventDefault(); + + this.trigger_up('snippet_will_be_cloned', {$target: this.$target}); + var $clone = this.$target.clone(false); this.trigger_up('request_history_undo_record', {$target: this.$target}); @@ -352,7 +355,7 @@ var SnippetEditor = Widget.extend({ } }, }); - this.trigger_up('snippet_cloned', {$target: $clone}); + this.trigger_up('snippet_cloned', {$target: $clone, $origin: this.$target}); }, /** * Called when the overlay dimensions/positions should be recomputed. -- cgit v1.2.3