Skip to content

Commit

Permalink
fix(protocol-designer): add fallback for well order (#16956)
Browse files Browse the repository at this point in the history
This fixes a case where in batch edit move liquid toolbox, well order
was set to null, displaying an
unknown translation in the WellOrder component. This PR refactors the
util used to set the first and
second well order values, providing a fallback if the value is null.
  • Loading branch information
ncdiehl11 authored Nov 22, 2024
1 parent 171d198 commit 95aa2f7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
getBlowoutLocationOptionsForForm,
getLabwareFieldForPositioningField,
} from '../StepForm/utils'

import type { WellOrderOption } from '../../../../form-types'
import type { FieldPropsByName } from '../StepForm/types'

Expand Down Expand Up @@ -59,17 +60,6 @@ export function BatchEditMixTools(props: BatchEditMixToolsProps): JSX.Element {
return pipetteId ? String(pipetteId) : null
}

const getWellOrderFieldValue = (
name: string
): WellOrderOption | null | undefined => {
const val = propsForFields[name]?.value
if (val === 'l2r' || val === 'r2l' || val === 't2b' || val === 'b2t') {
return val
} else {
return null
}
}

return (
<Flex
flexDirection={DIRECTION_COLUMN}
Expand Down Expand Up @@ -101,8 +91,14 @@ export function BatchEditMixTools(props: BatchEditMixToolsProps): JSX.Element {
updateSecondWellOrder={
propsForFields.mix_wellOrder_second.updateValue
}
firstValue={getWellOrderFieldValue('mix_wellOrder_first')}
secondValue={getWellOrderFieldValue('mix_wellOrder_second')}
firstValue={
(propsForFields.mix_wellOrder_first.name ??
't2b') as WellOrderOption
}
secondValue={
(propsForFields.mix_wellOrder_second.name ??
'l2r') as WellOrderOption
}
firstName="mix_wellOrder_first"
secondName="mix_wellOrder_second"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,6 @@ export function BatchEditMoveLiquidTools(
const labwareId = propsForFields[labwareField]?.value
return labwareId ? String(labwareId) : null
}
const getWellOrderFieldValue = (
name: string
): WellOrderOption | null | undefined => {
const val = propsForFields[name]?.value
if (val === 'l2r' || val === 'r2l' || val === 't2b' || val === 'b2t') {
return val
} else {
return null
}
}

return (
<Flex
Expand Down Expand Up @@ -100,12 +90,12 @@ export function BatchEditMoveLiquidTools(
updateSecondWellOrder={
propsForFields[addFieldNamePrefix('wellOrder_second')].updateValue
}
firstValue={getWellOrderFieldValue(
addFieldNamePrefix('wellOrder_first')
)}
secondValue={getWellOrderFieldValue(
addFieldNamePrefix('wellOrder_second')
)}
firstValue={
(propsForFields.wellOrder_first.name ?? 't2b') as WellOrderOption
}
secondValue={
(propsForFields.wellOrder_second.name ?? 'l2r') as WellOrderOption
}
firstName={addFieldNamePrefix('wellOrder_first')}
secondName={addFieldNamePrefix('wellOrder_second')}
/>
Expand Down

0 comments on commit 95aa2f7

Please sign in to comment.