Skip to content

Commit 944d7dd

Browse files
committed
fix(tables): merge only mutated keys in onSuccess to preserve concurrent optimistic patches
1 parent a0974d6 commit 944d7dd

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

apps/sim/hooks/queries/tables.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,13 +575,18 @@ export function useUpdateTableRow({ workspaceId, tableId }: RowMutationContext)
575575

576576
return { previousQueries }
577577
},
578-
onSuccess: (response, { rowId }) => {
578+
onSuccess: (response, { rowId, data: mutatedData }) => {
579579
const serverRow = response.data.row
580+
const mutatedKeys = Object.keys(mutatedData)
580581
patchCachedRows(queryClient, tableId, (row) => {
581582
if (row.id !== rowId) return row
583+
const merged: RowData = { ...row.data }
584+
for (const key of mutatedKeys) {
585+
merged[key] = (serverRow.data as RowData)[key]
586+
}
582587
return {
583588
...row,
584-
data: serverRow.data,
589+
data: merged,
585590
position: serverRow.position,
586591
createdAt: serverRow.createdAt,
587592
updatedAt: serverRow.updatedAt,

0 commit comments

Comments
 (0)