From 95947bc64d1b35c46cc2fd01a9227e814289729f Mon Sep 17 00:00:00 2001 From: Cyrine Ben Romdhane <135605630+anicyne@users.noreply.github.com> Date: Fri, 8 Nov 2024 11:43:31 +0100 Subject: [PATCH] Fix table column consistency Refs: #6890 --- .../components/table-stateless/component.tsx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/components/src/components/table-stateless/component.tsx b/packages/components/src/components/table-stateless/component.tsx index 370c80fe6e..9503fddb62 100644 --- a/packages/components/src/components/table-stateless/component.tsx +++ b/packages/components/src/components/table-stateless/component.tsx @@ -398,6 +398,23 @@ export class KolTableStateless implements TableStatelessAPI { dataField[0].push(emptyCell); } } + dataField.forEach((row, rowIndex) => { + if (row.length > maxCols) { + row = row.slice(0, maxCols); + } + + if (row.length < maxCols) { + const missingColumns = maxCols - row.length; + for (let i = 0; i < missingColumns; i++) { + row.push({ + label: '', + colSpan: undefined, + rowSpan: undefined, + }); + } + } + dataField[rowIndex] = row; + }); return dataField; }