Skip to content

Commit

Permalink
Revert "fix(app): fix WellSelection over-render (#16457)"
Browse files Browse the repository at this point in the history
This reverts commit 3254494.
  • Loading branch information
mjhuff authored Oct 10, 2024
1 parent 3254494 commit c3ce932
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 38 deletions.
5 changes: 1 addition & 4 deletions app/src/organisms/ErrorRecoveryFlows/__fixtures__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,7 @@ export const mockRecoveryContentProps: RecoveryContentProps = {
recoveryCommands: {} as any,
tipStatusUtils: {} as any,
currentRecoveryOptionUtils: {} as any,
failedLabwareUtils: {
pickUpTipLabware: mockPickUpTipLabware,
selectedTipLocation: { A1: null },
} as any,
failedLabwareUtils: { pickUpTipLabware: mockPickUpTipLabware } as any,
failedPipetteInfo: {} as any,
deckMapUtils: { setSelectedLocation: () => {} } as any,
stepCounts: {} as any,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('useRecoveryCommands', () => {
} as any
const mockRunId = '123'
const mockFailedLabwareUtils = {
selectedTipLocation: { A1: null },
selectedTipLocations: { A1: null },
pickUpTipLabware: { id: 'MOCK_LW_ID' },
} as any
const mockProceedToRouteAndStep = vi.fn()
Expand Down Expand Up @@ -223,7 +223,7 @@ describe('useRecoveryCommands', () => {
} as any

const buildPickUpTipsCmd = buildPickUpTips(
mockFailedLabwareUtils.selectedTipLocation,
mockFailedLabwareUtils.selectedTipLocations,
mockFailedCmdWithPipetteId,
mockFailedLabware
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function getRelevantPickUpTipCommand(

interface UseTipSelectionUtilsResult {
/* Always returns null if the relevant labware is not relevant to tip pick up. */
selectedTipLocation: WellGroup | null
selectedTipLocations: WellGroup | null
tipSelectorDef: LabwareDefinition2
selectTips: (tipGroup: WellGroup) => void
deselectTips: (locations: string[]) => void
Expand Down Expand Up @@ -220,7 +220,7 @@ function useTipSelectionUtils(
selectedLocs != null && Object.keys(selectedLocs).length > 0

return {
selectedTipLocation: selectedLocs,
selectedTipLocations: selectedLocs,
tipSelectorDef,
selectTips,
deselectTips,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,10 @@ export function useRecoveryCommands({

// Pick up the user-selected tips
const pickUpTips = useCallback((): Promise<CommandData[]> => {
const { selectedTipLocation, failedLabware } = failedLabwareUtils
const { selectedTipLocations, failedLabware } = failedLabwareUtils

const pickUpTipCmd = buildPickUpTips(
selectedTipLocation,
selectedTipLocations,
failedCommandByRunRecord,
failedLabware
)
Expand Down
4 changes: 2 additions & 2 deletions app/src/organisms/ErrorRecoveryFlows/shared/TipSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function TipSelection(props: TipSelectionProps): JSX.Element {

const {
tipSelectorDef,
selectedTipLocation,
selectedTipLocations,
selectTips,
deselectTips,
} = failedLabwareUtils
Expand All @@ -33,7 +33,7 @@ export function TipSelection(props: TipSelectionProps): JSX.Element {
<WellSelection
definition={tipSelectorDef}
deselectWells={onDeselectTips}
selectedPrimaryWell={Object.keys(selectedTipLocation as WellGroup)[0]}
selectedPrimaryWells={selectedTipLocations as WellGroup}
selectWells={onSelectTips}
channels={failedPipetteInfo?.data.channels ?? 1}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('TipSelection', () => {
expect(vi.mocked(WellSelection)).toHaveBeenCalledWith(
expect.objectContaining({
definition: props.failedLabwareUtils.tipSelectorDef,
selectedPrimaryWell: 'A1',
selectedPrimaryWells: props.failedLabwareUtils.selectedTipLocations,
channels: props.failedPipetteInfo?.data.channels ?? 1,
}),
{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export function SelectDestWells(props: SelectDestWellsProps): JSX.Element {
)
)
}}
selectedPrimaryWell={Object.keys(selectedWells)[0]}
selectedPrimaryWells={selectedWells}
selectWells={wellGroup => {
if (Object.keys(wellGroup).length > 0) {
setIsNumberWellsSelectedError(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export function SelectSourceWells(props: SelectSourceWellsProps): JSX.Element {
)
)
}}
selectedPrimaryWell={Object.keys(selectedWells)[0]}
selectedPrimaryWells={selectedWells}
selectWells={wellGroup => {
setSelectedWells(prevWells => ({ ...prevWells, ...wellGroup }))
}}
Expand Down
43 changes: 20 additions & 23 deletions app/src/organisms/WellSelection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ import type { GenericRect } from './types'
interface WellSelectionProps {
definition: LabwareDefinition2
deselectWells: (wells: string[]) => void
/* A well from which to derive the well set.
* If utilizing this component specifically in the context of a command, this should be the 'wellName'. */
selectedPrimaryWell: string
selectedPrimaryWells: WellGroup
selectWells: (wellGroup: WellGroup) => unknown
channels: PipetteChannels
}
Expand All @@ -31,7 +29,7 @@ export function WellSelection(props: WellSelectionProps): JSX.Element {
const {
definition,
deselectWells,
selectedPrimaryWell,
selectedPrimaryWells,
selectWells,
channels,
} = props
Expand All @@ -52,9 +50,7 @@ export function WellSelection(props: WellSelectionProps): JSX.Element {
wellName,
channels,
})
if (!wellSet) {
return acc
}
if (!wellSet) return acc
return { ...acc, [wellSet[0]]: null }
},
{}
Expand Down Expand Up @@ -104,22 +100,23 @@ export function WellSelection(props: WellSelectionProps): JSX.Element {
setHighlightedWells({})
}

// For rendering, show all valid wells, not just primary wells
const buildAllSelectedWells = (): WellGroup => {
if (channels === 8 || channels === 96) {
const wellSet = getWellSetForMultichannel({
labwareDef: definition,
wellName: selectedPrimaryWell,
channels,
})

return wellSet != null ? arrayToWellGroup(wellSet) : {}
} else {
return { [selectedPrimaryWell]: null }
}
}

const allSelectedWells = buildAllSelectedWells()
// For rendering, show all wells not just primary wells
const allSelectedWells =
channels === 8 || channels === 96
? reduce<WellGroup, WellGroup>(
selectedPrimaryWells,
(acc, _, wellName): WellGroup => {
const wellSet = getWellSetForMultichannel({
labwareDef: definition,
wellName,
channels,
})
if (!wellSet) return acc
return { ...acc, ...arrayToWellGroup(wellSet) }
},
{}
)
: selectedPrimaryWells

const wellFill: WellFill = {}
const wellStroke: WellStroke = {}
Expand Down

0 comments on commit c3ce932

Please sign in to comment.