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 7ba72fbe71f..fe2089ecee4 100644 --- a/addons/web_editor/static/src/js/backend/convert_inline.js +++ b/addons/web_editor/static/src/js/backend/convert_inline.js @@ -429,9 +429,26 @@ function enforceTablesResponsivity(editable) { tr.style.setProperty('width', '100%'); } for (const td of editable.querySelectorAll('td[colspan]')) { - td.setAttribute('width', '100%'); - td.style.setProperty('width', '100%'); - td.style.setProperty('display', 'inline-block'); // Allow cells to wrap. + const colspan = +td.getAttribute('colspan'); + const tdSiblings = [...td.parentElement.children].filter(child => child.nodeName === 'TD'); + if ( // Don't allow little duos of columns to wrap (eg., col-2 col-10). + colspan > 2 && colspan < 10 || tdSiblings.length > 2 + || tdSiblings.some(td => [...td.children].some(child => child.style.width === '100%')) // Unless they have a full width child. + ) { + td.setAttribute('width', '100%'); + td.style.setProperty('width', '100%'); + td.style.setProperty('display', 'inline-block'); // Allow cells to wrap. + } else if (td.getAttribute('width') === '100%') { + if (td.children.length === 1 && td.firstElementChild.nodeName === 'IMG') { + const width = td.firstElementChild.getAttribute('width'); + td.setAttribute('width', width); + td.style.removeProperty('width'); + td.style.setProperty('min-width', width + 'px'); + } else { + td.removeAttribute('width'); + td.style.removeProperty('width'); + } + } } // Masonry has crazy nested tables that require some extra treatment. for (const td of editable.querySelectorAll('.s_masonry_block td')) {