From bf6bbd7c502283e65f2cb112a9df7d3c430c58db Mon Sep 17 00:00:00 2001 From: Jethary Rader <66035149+jerader@users.noreply.github.com> Date: Mon, 20 May 2024 13:45:36 -0400 Subject: [PATCH] fix(protocol-designer): default to correct tiprack uri (#15224) closes RQA-2709 --- .../StepEditForm/fields/TiprackField.tsx | 7 +++ .../test/createPresavedStepForm.test.ts | 4 +- .../utils/createPresavedStepForm.ts | 48 ------------------- 3 files changed, 9 insertions(+), 50 deletions(-) diff --git a/protocol-designer/src/components/StepEditForm/fields/TiprackField.tsx b/protocol-designer/src/components/StepEditForm/fields/TiprackField.tsx index 7c9f2cea2a0..dac7123e916 100644 --- a/protocol-designer/src/components/StepEditForm/fields/TiprackField.tsx +++ b/protocol-designer/src/components/StepEditForm/fields/TiprackField.tsx @@ -36,6 +36,13 @@ export function TiprackField(props: TiprackFieldProps): JSX.Element { defaultTiprackUris.includes(option.value) ) + React.useEffect(() => { + // if default value is not included in the pipette's tiprack uris then + // change it so it is + if (!defaultTiprackUris.includes(value as string)) { + updateValue(defaultTiprackUris[0]) + } + }, [defaultTiprackUris, value, updateValue]) const hasMissingTiprack = defaultTiprackUris.length > tiprackOptions.length return ( diff --git a/protocol-designer/src/step-forms/test/createPresavedStepForm.test.ts b/protocol-designer/src/step-forms/test/createPresavedStepForm.test.ts index 326cb5ab742..f7e37d2e467 100644 --- a/protocol-designer/src/step-forms/test/createPresavedStepForm.test.ts +++ b/protocol-designer/src/step-forms/test/createPresavedStepForm.test.ts @@ -141,7 +141,7 @@ describe('createPresavedStepForm', () => { pipette: 'leftPipetteId', nozzles: null, stepType: 'moveLiquid', - tipRack: 'defaultTipRack', + tipRack: null, // default fields dropTip_location: 'mockTrash', aspirate_airGap_checkbox: false, @@ -228,7 +228,7 @@ describe('createPresavedStepForm', () => { volume: undefined, aspirate_flowRate: null, dispense_flowRate: null, - tipRack: 'defaultTipRack', + tipRack: null, blowout_flowRate: null, }) }) diff --git a/protocol-designer/src/step-forms/utils/createPresavedStepForm.ts b/protocol-designer/src/step-forms/utils/createPresavedStepForm.ts index 56c5788f36e..387a3068a18 100644 --- a/protocol-designer/src/step-forms/utils/createPresavedStepForm.ts +++ b/protocol-designer/src/step-forms/utils/createPresavedStepForm.ts @@ -118,45 +118,6 @@ const _patchDefaultDropTipLocation = (args: { return null } -const _patchDefaultTiprack = (args: { - initialDeckSetup: InitialDeckSetup - labwareEntities: LabwareEntities - pipetteEntities: PipetteEntities - savedStepForms: SavedStepFormState - orderedStepIds: OrderedStepIdsState -}): FormUpdater => formData => { - const { - initialDeckSetup, - labwareEntities, - pipetteEntities, - savedStepForms, - orderedStepIds, - } = args - const defaultPipetteId = getNextDefaultPipetteId( - savedStepForms, - orderedStepIds, - initialDeckSetup.pipettes - ) - - const pipetteFirstTiprackDefUri = - pipetteEntities[defaultPipetteId].tiprackDefURI[0] - const formHasTipRackField = formData && 'tipRack' in formData - - if (formHasTipRackField) { - const updatedFields = handleFormChange( - { - tipRack: pipetteFirstTiprackDefUri, - }, - formData, - pipetteEntities, - labwareEntities - ) - return updatedFields - } - - return null -} - const _patchDefaultMagnetFields = (args: { initialDeckSetup: InitialDeckSetup orderedStepIds: OrderedStepIdsState @@ -312,14 +273,6 @@ export const createPresavedStepForm = ({ additionalEquipmentEntities, }) - const updateDefaultTipRack = _patchDefaultTiprack({ - initialDeckSetup, - labwareEntities, - orderedStepIds, - pipetteEntities, - savedStepForms, - }) - const updateDefaultPipette = _patchDefaultPipette({ initialDeckSetup, labwareEntities, @@ -360,7 +313,6 @@ export const createPresavedStepForm = ({ return [ updateDefaultPipette, updateDefaultDropTip, - updateDefaultTipRack, updateTemperatureModuleId, updateThermocyclerFields, updateHeaterShakerModuleId,