Skip to content

Commit

Permalink
fix: handle sample xref properties when xref is null (#1842)
Browse files Browse the repository at this point in the history
  • Loading branch information
adambasha0 authored Mar 28, 2024
1 parent 84c8806 commit cca1122
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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 (
<FormGroup bsSize={condition ? 'small' : null}>
<ControlLabel>{label}</ControlLabel>
<FormControl
id={`txinput_${field}`}
type="text"
value={(/^xref_/.test(field) ? sample.xref[field.split('xref_')[1]] : sample[field]) || ''}
value={updateValue}
onChange={(e) => { this.handleFieldChanged(field, e.target.value); }}
disabled={disabled || !sample.can_update}
readOnly={disabled || !sample.can_update}
Expand All @@ -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 (
<NumericInputUnit
field="flash_point"
Expand Down

0 comments on commit cca1122

Please sign in to comment.