Skip to content

Commit

Permalink
bugfix: added empty rows on table update
Browse files Browse the repository at this point in the history
  • Loading branch information
p-bemportato committed Jul 2, 2024
1 parent 1da3a2f commit caef80f
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions packages/ketchup/src/components/kup-input-panel/kup-input-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -852,27 +852,25 @@ export class KupInputPanel {
this.#originalData.rows[0].cells[cellId].value
);

updated.rows = tableValue.rows
.map((row, i) =>
editableColsId.reduce((cells, colId) => {
const changed =
row.cells[colId].value !==
beforeTableValue.rows[i].cells[colId].value;

if (changed) {
return {
...cells,
[colId]: {
...beforeTableValue.rows[i].cells[colId],
value: row.cells[colId].value,
},
};
}
updated.rows = tableValue.rows.map((row, i) =>
editableColsId.reduce((cells, colId) => {
const changed =
row.cells[colId].value !==
beforeTableValue.rows[i].cells[colId].value;

return cells;
}, {})
)
.filter((row) => Object.keys(row).length);
if (changed) {
return {
...cells,
[colId]: {
...beforeTableValue.rows[i].cells[colId],
value: row.cells[colId].value,
},
};
}

return cells;
}, {})
);

return updated;
} catch (e) {
Expand Down

0 comments on commit caef80f

Please sign in to comment.