Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions packages/core-data/src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,16 @@ export const editEntityRecord =
recordId
);

// Some fields are merged with the existing value instead of replaced.
// See `mergedEdits` definition on the entity config.
const editsWithMerges = Object.keys( edits ).reduce( ( acc, key ) => {
acc[ key ] = mergedEdits[ key ]
? { ...editedRecord[ key ], ...edits[ key ] }
: edits[ key ];

return acc;
}, {} );

const edit = {
kind,
name,
Expand All @@ -410,10 +420,7 @@ export const editEntityRecord =
// so that the property is not considered dirty.
edits: Object.keys( edits ).reduce( ( acc, key ) => {
const recordValue = record[ key ];
const editedRecordValue = editedRecord[ key ];
const value = mergedEdits[ key ]
? { ...editedRecordValue, ...edits[ key ] }
: edits[ key ];
const value = editsWithMerges[ key ];
acc[ key ] = fastDeepEqual( recordValue, value )
? undefined
: value;
Expand All @@ -428,7 +435,7 @@ export const editEntityRecord =
getSyncManager()?.update(
objectType,
objectId,
edit.edits,
editsWithMerges,
LOCAL_EDITOR_ORIGIN
);
}
Expand Down
Loading
Loading