From e8ee90f39ae41fcff8a580eadd67b094aff727fb Mon Sep 17 00:00:00 2001 From: Faton Ramadani Date: Fri, 27 Oct 2023 18:36:27 +0200 Subject: [PATCH] fix(frontend): fix insert new item (#2519) * fix(frontend): fix insert new item * fix(frontend): fix insert new item --- frontend/src/lib/components/apps/editor/appUtils.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/src/lib/components/apps/editor/appUtils.ts b/frontend/src/lib/components/apps/editor/appUtils.ts index 67dff46b76..6722c662d6 100644 --- a/frontend/src/lib/components/apps/editor/appUtils.ts +++ b/frontend/src/lib/components/apps/editor/appUtils.ts @@ -336,6 +336,12 @@ export function insertNewGridItem( const key = focusedGrid ? `${focusedGrid?.parentComponentId}-${focusedGrid?.subGridIndex ?? 0}` : undefined + + if (key && app.subgrids[key] === undefined) { + // If ever the subgrid is undefined, we want to make sure it is defined + app.subgrids[key] = [] + } + let grid = focusedGrid ? app.subgrids[key!] : app.grid const newItem = createNewGridItem(grid, id, data, columns) @@ -745,4 +751,3 @@ export function recursivelyFilterKeyInJSON( }) return filteredJSON } -