Skip to content

Commit

Permalink
fix(Grid): fixes data mutation in translateData utility
Browse files Browse the repository at this point in the history
Closes #265
  • Loading branch information
aditya-kumawat committed Aug 17, 2020
1 parent 58171e6 commit 447d9b5
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions core/components/organisms/grid/rowUtility.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,14 @@ export const updateBatchData = (data: Data, rowIndexes: number[], dataUpdate: Pa
};

export function translateData(schema: ColumnSchema, data: RowData) {
let newData = data;
const newData = { ...data };

if (schema.translate) {
const translatedData = schema.translate(data);
newData = {
...newData,
[schema.name]: typeof translatedData === 'object' ? {
...newData[schema.name],
...translatedData
} : translatedData
};
newData[schema.name] = (translatedData !== null && typeof translatedData === 'object') ? {
...newData[schema.name],
...translatedData
} : translatedData;
}
if (typeof newData[schema.name] !== 'object') newData[schema.name] = { title: newData[schema.name] };

Expand Down

0 comments on commit 447d9b5

Please sign in to comment.