Skip to content

Commit

Permalink
Merge pull request #1974 from apuliasoft/inputpanel
Browse files Browse the repository at this point in the history
bugfix: update table value in input panel
  • Loading branch information
lucafoscili authored Jul 2, 2024
2 parents 356ff83 + caef80f commit 6b573f6
Showing 1 changed file with 20 additions and 23 deletions.
43 changes: 20 additions & 23 deletions packages/ketchup/src/components/kup-input-panel/kup-input-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -532,9 +532,8 @@ export class KupInputPanel {
let value: any = cellState?.value;

if (cellState.shape === FCellShapes.TABLE) {
value = this.#getTableUpdatedCell(
cellState.data,
key
value = JSON.stringify(
this.#getTableUpdatedCell(cellState.data, key)
);
}

Expand Down Expand Up @@ -853,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 6b573f6

Please sign in to comment.