Skip to content

Commit

Permalink
fix(ui-tablemode): handle null values in string cells for Handsontabl…
Browse files Browse the repository at this point in the history
…e's afterChange event
  • Loading branch information
hdinia committed Aug 4, 2023
1 parent eefd7c3 commit 19ce885
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions webapp/src/components/common/FormTable/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ function Table(props: TableProps) {

const handleAfterChange: HandsontableProps["afterChange"] =
function afterChange(this: unknown, changes, ...rest): void {
changes?.forEach(([row, column, _, nextValue]) => {
setValue(`${data[row].id}.${column}`, nextValue ?? "");
changes?.forEach(([row, column, prevValue, nextValue]) => {
if (typeof prevValue === "string" && nextValue === null) {
setValue(`${data[row].id}.${column}`, "");
} else {
setValue(`${data[row].id}.${column}`, nextValue);
}
});
restProps.afterChange?.call(this, changes, ...rest);
};
Expand Down

0 comments on commit 19ce885

Please sign in to comment.