From 5418f939031803b0b89d20bce4151925acdc9f1b Mon Sep 17 00:00:00 2001 From: Gorash Date: Fri, 16 Oct 2020 10:45:57 +0000 Subject: [PATCH] [FIX] web_editor: need to build the snippet before commit it into vDom Issue: Add dynamic carousel in the page, then change the footer template, then reply "Yes, I want to save & reload", then the page is broken because the new class and data attributes are not saved. closes odoo/odoo#60077 Signed-off-by: David Monjoie (dmo) --- .../static/src/js/editor/snippets.editor.js | 13 ++++++------- .../static/src/snippets/s_website_form/options.js | 5 +---- 2 files changed, 7 insertions(+), 11 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 a3ef2e3d784..308e54f4bc7 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -2068,19 +2068,18 @@ var SnippetsMenu = Widget.extend({ _.defer(async () => { self.trigger_up('snippet_dropped', {$target: $snippetToInsert}); + + await self._callForEachChildSnippet($snippetToInsert, function (editor) { + return editor.buildSnippet(); + }); + const jwEditor = self.wysiwyg.editor; const vNodes = await self._insertSnippet($snippetToInsert); - const layout = jwEditor.plugins.get(self.JWEditorLib.Layout); - const domLayout = layout.engines.dom; - const domNode = domLayout.getDomNodes(vNodes[0])[0]; + self._disableUndroppableSnippets(); self.dragAndDropResolve(); - await self._callForEachChildSnippet($(domNode), function (editor) { - return editor.buildSnippet(); - }); - $snippetToInsert.trigger('content_changed'); await self._updateInvisibleDOM(); diff --git a/addons/website_form/static/src/snippets/s_website_form/options.js b/addons/website_form/static/src/snippets/s_website_form/options.js index a00cfa92c1b..45a255dbb56 100644 --- a/addons/website_form/static/src/snippets/s_website_form/options.js +++ b/addons/website_form/static/src/snippets/s_website_form/options.js @@ -359,10 +359,7 @@ snippetOptions.registry.WebsiteFormEditor = FormEditor.extend({ // If the form has no model it means a new snippet has been dropped. // Apply the default model selected in willStart on it. if (!this.$target[0].dataset.model_name) { - proms.push((async () => { - await this._applyFormModel(); - await this.updateChangesInWysiwyg(); - })()); + proms.push(this._applyFormModel()); } await Promise.all(proms);