diff --git a/src/components/modules/TransferModule/TransferItemModal/TransferItemModal.tsx b/src/components/modules/TransferModule/TransferItemModal/TransferItemModal.tsx index 919dec3f..7923e53b 100644 --- a/src/components/modules/TransferModule/TransferItemModal/TransferItemModal.tsx +++ b/src/components/modules/TransferModule/TransferItemModal/TransferItemModal.tsx @@ -632,11 +632,11 @@ class TransferItemModal extends React.Component { ? { ...this.state.sourceData } : { ...this.state.destinationData }; + const replicaData: any = + type === "source" + ? this.props.replica.source_environment + : this.props.replica.destination_environment; if (field.type === "array") { - const replicaData: any = - type === "source" - ? this.props.replica.source_environment - : this.props.replica.destination_environment; const currentValues: string[] = data[field.name] || []; const oldValues: string[] = replicaData[field.name] || []; let values: string[] = currentValues; @@ -654,7 +654,11 @@ class TransferItemModal extends React.Component { } data[field.groupName][field.name] = value; } else if (parentFieldName) { - data[parentFieldName] = data[parentFieldName] || {}; + // NOTE(aznashwan): in order to prevent accidentally un-setting any + // existing fields from Object options from the previous Migration/Replica, + // we always re-merge all the values on an object field update. + data[parentFieldName] = + data[parentFieldName] || replicaData[parentFieldName] || {}; data[parentFieldName][field.name] = value; } else { data[field.name] = value;