From 4a2e7d3bdf1d15ec8ef46ecdbe0e5e3108a58bc0 Mon Sep 17 00:00:00 2001 From: Sherfin Shamsudeen Date: Thu, 27 Oct 2022 12:56:47 +0530 Subject: [PATCH] Do not auto generate columns for nested data (#4627) --- .../Editor/Components/Table/columns/autogenerateColumns.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/src/Editor/Components/Table/columns/autogenerateColumns.js b/frontend/src/Editor/Components/Table/columns/autogenerateColumns.js index f000598452..bf413e4b41 100644 --- a/frontend/src/Editor/Components/Table/columns/autogenerateColumns.js +++ b/frontend/src/Editor/Components/Table/columns/autogenerateColumns.js @@ -4,7 +4,11 @@ import { v4 as uuidv4 } from 'uuid'; export default function autogenerateColumns(tableData, existingColumns, columnDeletionHistory, setProperty) { const firstRow = tableData?.[0] ?? {}; - const keysOfTableData = Object.keys(firstRow); + const firstRowWithoutNestedElements = Object.fromEntries( + Object.entries(firstRow).filter(([_key, value]) => typeof value != 'object') + ); + + const keysOfTableData = Object.keys(firstRowWithoutNestedElements); const keysOfExistingColumns = existingColumns.map((column) => column.key || column.name);