From 29fac54b1407a68ace987b2f06c4efe355a9a887 Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Mon, 15 Nov 2021 16:27:11 +0000 Subject: [PATCH] [FIX] web_editor: properly add nested tables where needed There was dead code in `addTables` that would never get triggered. When fixing that, the code crashed because of a reference to the wrong variable. Those two problems are hereby fixed. X-original-commit: 21dccd1521c654eb9723a93bceda8e3e3ec8cc6a Part-of: odoo/odoo#81540 --- addons/web_editor/static/src/js/backend/convert_inline.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/web_editor/static/src/js/backend/convert_inline.js b/addons/web_editor/static/src/js/backend/convert_inline.js index 41c6c835f35..d9082ca3780 100644 --- a/addons/web_editor/static/src/js/backend/convert_inline.js +++ b/addons/web_editor/static/src/js/backend/convert_inline.js @@ -638,14 +638,14 @@ function addTables($editable) { $(snippet).remove(); // If snippet doesn't have a table as child, wrap its contents in one. - if (!$col.children().filter('table')) { + if (!$col.children().filter('table').length) { const $tableB = _createTable(); $tableB[0].style.width const $rowB = $(''); const $colB = $(''); $rowB.append($colB); $tableB.append($rowB); - for (const child of [...$table[0].childNodes]) { + for (const child of [...$col[0].childNodes]) { $colB.append(child); } $col.append($tableB);