Skip to content

Commit 6bee9ba

Browse files
anaisbergSimonClo
authored andcommitted
🐛 add row after creating columns
1 parent d5600be commit 6bee9ba

File tree

1 file changed

+6
-3
lines changed
  • src/frontend/apps/impress/src/features/docs/doc-editor/components/custom-blocks/DatabaseBlock

1 file changed

+6
-3
lines changed

src/frontend/apps/impress/src/features/docs/doc-editor/components/custom-blocks/DatabaseBlock/DatabaseGrid.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,8 @@ export const DatabaseGrid = ({
7676

7777
setRowData(rowData1);
7878

79-
const addNewRow = createNewRow('+ new row', colDefs ?? []);
80-
rowData1.push(addNewRow);
81-
8279
const columnNames = Object.keys(Object.fromEntries(filteredEntries));
80+
8381
const columns: ColDef[] = columnNames.map((key) => ({
8482
field: key,
8583
colSpan: newRowColSpan,
@@ -105,6 +103,11 @@ export const DatabaseGrid = ({
105103
// eslint-disable-next-line react-hooks/exhaustive-deps
106104
}, [tableData]);
107105

106+
useEffect(() => {
107+
const addNewRow = createNewRow('+ new row', colDefs ?? []);
108+
setRowData((prev) => [...(prev ? prev : []), addNewRow]);
109+
}, [colDefs, gridRef, setRowData]);
110+
108111
const defaultColDef = {
109112
flex: 1,
110113
filter: true,

0 commit comments

Comments
 (0)