From 0a77f3279f3fd8a10274042cbadcbbc4de0e1e02 Mon Sep 17 00:00:00 2001 From: "Rodopho Cammarosano de Lima (rcdl)" Date: Thu, 2 Feb 2023 12:56:04 +0000 Subject: [PATCH] [FIX] web_editor: fix unbreakable rollback upon column number change When wrapping the contents of a paragraph into a newly created div, the nodes' ouid (unbreakable id) must be reset in order to prevent a "unbreakable" rollback. This commit makes such property reset and fixes errors related to changing the number of columns of a text snippet. task-3165895 opw-3137951 closes odoo/odoo#112521 X-original-commit: e33b802b05b41df20e13ebc44bc5b78edae50bb8 Signed-off-by: David Monjoie (dmo) --- addons/web_editor/static/src/js/editor/snippets.options.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/addons/web_editor/static/src/js/editor/snippets.options.js b/addons/web_editor/static/src/js/editor/snippets.options.js index 1905f2e2231..d259fcc3a72 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -38,6 +38,7 @@ const {SIZES, MEDIAS_BREAKPOINTS} = require('@web/core/ui/ui_service'); var qweb = core.qweb; var _t = core._t; const preserveCursor = OdooEditorLib.preserveCursor; +const descendants = OdooEditorLib.descendants; /** * @param {HTMLElement} el @@ -4983,6 +4984,9 @@ registry.layout_column = SnippetOptionWidget.extend({ let $row = this.$('> .row'); if (!$row.length) { const restoreCursor = preserveCursor(this.$target[0].ownerDocument); + for (const node of descendants(this.$target[0])) { + node.ouid = undefined; + } $row = this.$target.contents().wrapAll($('
')).parent().parent(); restoreCursor(); } @@ -4995,6 +4999,9 @@ registry.layout_column = SnippetOptionWidget.extend({ await new Promise(resolve => setTimeout(resolve)); if (nbColumns === 0) { const restoreCursor = preserveCursor(this.$target[0].ownerDocument); + for (const node of descendants($row[0])) { + node.ouid = undefined; + } $row.contents().unwrap().contents().unwrap(); restoreCursor(); this.trigger_up('activate_snippet', {$snippet: this.$target});