diff --git a/app/packs/src/apps/mydb/elements/details/samples/propertiesTab/SampleForm.js b/app/packs/src/apps/mydb/elements/details/samples/propertiesTab/SampleForm.js index 40a0d59dab..2001639f88 100644 --- a/app/packs/src/apps/mydb/elements/details/samples/propertiesTab/SampleForm.js +++ b/app/packs/src/apps/mydb/elements/details/samples/propertiesTab/SampleForm.js @@ -312,6 +312,7 @@ export default class SampleForm extends React.Component { const object = { value: e, unit }; sample.xref = { ...sample.xref, flash_point: object }; } else if (/^xref_/.test(field)) { + sample.xref ||= {}; const key = field.split('xref_')[1]; sample.xref[key] = e; } else if (e && (e.value || e.value === 0)) { @@ -343,13 +344,15 @@ export default class SampleForm extends React.Component { textInput(sample, field, label, disabled = false) { const condition = field !== 'external_label' && field !== 'xref_inventory_label' && field !== 'name'; + const updateValue = (/^xref_/.test(field) && sample.xref + ? sample.xref[field.split('xref_')[1]] : sample[field]) || ''; return ( {label} { this.handleFieldChanged(field, e.target.value); }} disabled={disabled || !sample.can_update} readOnly={disabled || !sample.can_update} @@ -359,8 +362,8 @@ export default class SampleForm extends React.Component { } inputWithUnit(sample, field, label) { - const value = sample.xref[field.split('xref_')[1]] ? sample.xref[field.split('xref_')[1]].value : ''; - const unit = sample.xref[field.split('xref_')[1]] ? sample.xref[field.split('xref_')[1]].unit : '°C'; + const value = sample.xref && sample.xref[field.split('xref_')[1]] ? sample.xref[field.split('xref_')[1]].value : ''; + const unit = sample.xref && sample.xref[field.split('xref_')[1]] ? sample.xref[field.split('xref_')[1]].unit : '°C'; return (