File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
src/frontend/apps/impress/src/features/docs/doc-editor/components/custom-blocks/DatabaseBlock Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 5
5
ICellRendererParams ,
6
6
} from 'ag-grid-community' ;
7
7
import { AgGridReact } from 'ag-grid-react' ;
8
- import { useCallback , useEffect } from 'react' ;
8
+ import { useCallback , useEffect , useMemo } from 'react' ;
9
9
10
10
import { Box } from '@/components' ;
11
11
import {
@@ -88,7 +88,7 @@ export const DatabaseGrid = ({
88
88
// eslint-disable-next-line react-hooks/exhaustive-deps
89
89
} , [ tableData ] ) ;
90
90
91
- useEffect ( ( ) => {
91
+ const addNewRow = useMemo ( ( ) => {
92
92
const columnNames = getColumnNames ( colDefs ) ;
93
93
const lastRow = rowData ?. [ rowData . length - 1 ] ;
94
94
if ( lastRow && Object . values ( lastRow ) . length > 0 ) {
@@ -97,8 +97,9 @@ export const DatabaseGrid = ({
97
97
return ;
98
98
}
99
99
}
100
- const addNewRow = createNewRow ( { value : ADD_NEW_ROW , columnNames } ) ;
101
- setRowData ( ( prev ) => [ ...( prev ? prev : [ ] ) , addNewRow ] ) ;
100
+ const newRow = createNewRow ( { value : ADD_NEW_ROW , columnNames } ) ;
101
+
102
+ return newRow ;
102
103
// eslint-disable-next-line react-hooks/exhaustive-deps
103
104
} , [ colDefs ] ) ;
104
105
@@ -167,6 +168,7 @@ export const DatabaseGrid = ({
167
168
domLayout = "autoHeight"
168
169
enableCellSpan = { true }
169
170
onCellEditingStopped = { onCellEditingStopped }
171
+ pinnedBottomRowData = { [ addNewRow ] }
170
172
/>
171
173
</ Box >
172
174
< AddButtonComponent addColumn = { addColumn } />
You can’t perform that action at this time.
0 commit comments