From db1920df4fbac251e88c37cb06fbb5808f8394bc Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Mon, 15 Nov 2021 15:42:30 +0000 Subject: [PATCH] [FIX] web_editor: bubble up pixel height to first applicable ancestor A percentage height will only be applied on an element whose parent has a set pixel height. This is why convert_inline applies a pixel height to the parent of each element with a percentage height when possible. But it failed in the case where said parent also had a percentage height. This keeps looking up the tree until we find an appropriate suitor for that pixel height. X-original-commit: a9b0184087bec08db523a02068cc3d04b5f1381e Part-of: odoo/odoo#81540 --- .../static/src/js/backend/convert_inline.js | 12 ++++++++++-- 1 file changed, 10 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 dc00f303b18..a2f55ccd6e5 100644 --- a/addons/web_editor/static/src/js/backend/convert_inline.js +++ b/addons/web_editor/static/src/js/backend/convert_inline.js @@ -693,7 +693,7 @@ function formatTables($editable) { } // Ensure a tbody in every table and cancel its default style. for (const table of $editable.find('table:not(:has(tbody))')) { - $(table).contents().wrap(''); + $(table).contents().wrap(''); } // Children will only take 100% height if the parent has a height property. for (const node of $editable.find('*').filter((i, n) => ( @@ -701,7 +701,15 @@ function formatTables($editable) { !n.parentElement.style.getPropertyValue('height') || n.parentElement.style.getPropertyValue('height').includes('%')) ))) { - node.parentElement.style.setProperty('height', '0'); + let parent = node.parentElement; + let height = parent.style.getPropertyValue('height'); + while (parent && height && height.includes('%')) { + parent = parent.parentElement; + height = parent.style.getPropertyValue('height'); + } + if (parent) { + parent.style.setProperty('height', '0'); + } } }