diff --git a/packages/nc-gui/composables/useViewData.ts b/packages/nc-gui/composables/useViewData.ts index 0776603b5c..bcce865df4 100644 --- a/packages/nc-gui/composables/useViewData.ts +++ b/packages/nc-gui/composables/useViewData.ts @@ -260,6 +260,12 @@ export function useViewData( ) if (!undo) { + Object.assign(currentRow, { + row: { ...insertedData, ...row }, + rowMeta: { ...(currentRow.rowMeta || {}), new: undefined }, + oldRow: { ...insertedData }, + }) + const id = extractPkFromRow(insertedData, metaValue?.columns as ColumnType[]) const pkData = rowPkData(insertedData, metaValue?.columns as ColumnType[]) const rowIndex = findIndexByPk(pkData) @@ -297,20 +303,12 @@ export function useViewData( undo: { fn: async function undo(this: UndoRedoAction, id: string) { await deleteRowById(id) - const pk: Record = rowPkData(row.row, meta?.value?.columns as ColumnType[]) - const rowIndex = findIndexByPk(pk) if (rowIndex) formattedData.value.splice(rowIndex, 1) }, args: [id], }, scope: defineViewScope({ view: viewMeta.value }), }) - - Object.assign(currentRow, { - row: { ...insertedData, ...row }, - rowMeta: { ...(currentRow.rowMeta || {}), new: undefined }, - oldRow: { ...insertedData }, - }) } await syncCount()