[FIX] web_editor: unneed size set when adding a row above a table

Reproduction:

1. In project -> task, create a new task
2. In the description, make a table of 1 row 2 columns, type two line
long string in the second cell
3. Create a row above, type anything short, save
4. Add the portal user as follower, e.g. search user joel
5. In an incognito tab log in with portal portal, check the task and the
table is out of the field

Fix: we should not fix the columns' width when create a new head row in
the table, for extra long table, it should be scrollable

task-3559104

closes odoo/odoo#154715

X-original-commit: 997b2f2817efe06ea37e5aca278507e0ef878635
Signed-off-by: Jinjiu Liu (jili) <jili@odoo.com>
Signed-off-by: Antoine Guenet (age) <age@odoo.com>
This commit is contained in:
Jinjiu Liu
2024-02-20 14:57:31 +00:00
parent 019aeb057b
commit 868d4f839a
2 changed files with 3 additions and 5 deletions
@@ -256,7 +256,7 @@
<div class="d-flex my-2">
<h5>Description</h5>
</div>
<div class="py-1 px-2 bg-100 small" t-field="task.description"/>
<div class="py-1 px-2 bg-100 small table-responsive" t-field="task.description"/>
</div>
<div t-if="task.attachment_ids" t-attf-class="col-12 o_project_portal_attachments {{'col-lg-6' if task.description else 'col-lg-12'}}">
<hr class="mb-1 d-none d-lg-block"/>
@@ -773,7 +773,6 @@ export const editorCommands = {
const newRow = document.createElement('tr');
newRow.style.height = referenceRowHeight + 'px';
const cells = referenceRow.querySelectorAll('td');
const referenceRowWidths = [...cells].map(cell => cell.style.width || cell.clientWidth + 'px');
newRow.append(...Array.from(Array(cells.length)).map(() => {
const td = document.createElement('td');
const p = document.createElement('p');
@@ -783,11 +782,10 @@ export const editorCommands = {
}));
referenceRow[beforeOrAfter](newRow);
newRow.style.height = referenceRowHeight + 'px';
// Preserve the width of the columns (applied only on the first row).
if (getRowIndex(newRow) === 0) {
let columnIndex = 0;
for (const column of newRow.children) {
column.style.width = referenceRowWidths[columnIndex];
for (const newColumn of newRow.children) {
newColumn.style.width = cells[columnIndex].style.width;
cells[columnIndex].style.width = '';
columnIndex++;
}