Skip to content

Commit 9c22e13

Browse files
fix(components): Fix module positioning in more deck maps (#18874)
Exactly the same thing as #18871 / EXEC-1645, just in different places.
1 parent e08d5db commit 9c22e13

File tree

4 files changed

+42
-20
lines changed

4 files changed

+42
-20
lines changed

components/src/hardware-sim/BaseDeck/BaseDeck.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,8 @@ export function BaseDeck(props: BaseDeckProps): JSX.Element {
303303
slotPosition[0]
304304
)}
305305
innerProps={innerProps}
306+
targetDeckId={deckDef.otId}
307+
targetSlotId={moduleLocation.slotName}
306308
>
307309
{nestedLabwareDef != null ? (
308310
<g cursor={onLabwareClick != null ? 'pointer' : ''}>
@@ -361,6 +363,8 @@ export function BaseDeck(props: BaseDeckProps): JSX.Element {
361363
slotPosition[0]
362364
)}
363365
innerProps={innerProps}
366+
targetDeckId={deckDef.otId}
367+
targetSlotId={moduleLocation.slotName}
364368
>
365369
{nestedLabwareDef != null ? (
366370
<g

components/src/hardware-sim/Module/index.tsx

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
HEATERSHAKER_MODULE_TYPE,
66
MAGNETIC_BLOCK_TYPE,
77
MAGNETIC_MODULE_TYPE,
8-
OT2_STANDARD_DECKID,
98
TEMPERATURE_MODULE_TYPE,
109
THERMOCYCLER_MODULE_TYPE,
1110
} from '@opentrons/shared-data'
@@ -52,8 +51,17 @@ interface Props {
5251
| {}
5352
statusInfo?: ReactNode // contents of small status rectangle, not displayed if absent
5453
children?: ReactNode // contents to be rendered on top of the labware mating surface of the module
55-
targetSlotId?: string
56-
targetDeckId?: string
54+
55+
/**
56+
* Used for applying slot-specific positioning adjustments.
57+
* If you're rendering the module on a deck, supply this for correct positioning.
58+
*/
59+
targetSlotId: string | null
60+
/**
61+
* Used for applying slot-specific positioning adjustments.
62+
* If you're rendering the module on a deck, supply this for correct positioning.
63+
*/
64+
targetDeckId: string | null
5765
}
5866

5967
const statusInfoWrapperProps = {
@@ -80,8 +88,9 @@ export const Module = (props: Props): JSX.Element => {
8088
statusInfo,
8189
children,
8290
targetSlotId,
83-
targetDeckId = OT2_STANDARD_DECKID,
91+
targetDeckId,
8492
} = props
93+
8594
const moduleType = getModuleType(def.model)
8695

8796
const { x: labwareOffsetX, y: labwareOffsetY } = def.labwareOffset
@@ -110,31 +119,28 @@ export const Module = (props: Props): JSX.Element => {
110119
let nestedLabwareOffsetY = labwareOffsetY
111120

112121
// additional transforms to apply to vectors in certain deck/slot combinations
113-
const transformsForDeckBySlot = def?.slotTransforms?.[targetDeckId]
122+
const transformsForDeckBySlot =
123+
(targetDeckId != null ? def?.slotTransforms?.[targetDeckId] : null) ?? {}
114124
const slotTransformsForDeckSlot =
115-
targetSlotId != null &&
116-
transformsForDeckBySlot != null &&
117-
targetSlotId in transformsForDeckBySlot
118-
? transformsForDeckBySlot[targetSlotId]
119-
: null
120-
const deckSpecificTransforms = slotTransformsForDeckSlot ?? {}
121-
if (deckSpecificTransforms?.cornerOffsetFromSlot != null) {
125+
(targetSlotId != null ? transformsForDeckBySlot[targetSlotId] : null) ?? {}
126+
127+
if (slotTransformsForDeckSlot.cornerOffsetFromSlot != null) {
122128
const [
123129
[slotTranslateX],
124130
[slotTranslateY],
125-
] = multiplyMatrices(deckSpecificTransforms.cornerOffsetFromSlot, [
131+
] = multiplyMatrices(slotTransformsForDeckSlot.cornerOffsetFromSlot, [
126132
[translateX],
127133
[translateY],
128134
[translateZ],
129135
[1],
130136
])
131137
offsetTransform = `translate(${slotTranslateX}, ${slotTranslateY})`
132138
}
133-
if (deckSpecificTransforms?.labwareOffset != null) {
139+
if (slotTransformsForDeckSlot.labwareOffset != null) {
134140
const [
135141
[slotLabwareOffsetX],
136142
[slotLabwareOffsetY],
137-
] = multiplyMatrices(deckSpecificTransforms.labwareOffset, [
143+
] = multiplyMatrices(slotTransformsForDeckSlot.labwareOffset, [
138144
[labwareOffsetX],
139145
[labwareOffsetY],
140146
[1],

protocol-designer/src/pages/Designer/DeckSetup/SelectedItems.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,20 @@ export const SelectedItems = (props: SelectedItemsProps): JSX.Element => {
103103
slotPosition != null &&
104104
orientation != null ? (
105105
<>
106+
{/*
107+
todo(mm, 2025-07-10): This <Module> and <ModuleLabel> positioning is not
108+
quite right, most obviously for the Thermocycler on a Flex. We aren't
109+
passing a targetSlotId and targetDeckId down to <Module>, which means
110+
it isn't applying slot-specific adjustments.
111+
*/}
106112
<Module
107113
key={`${selectedModuleModel}_${selectedSlot.slot}_selected`}
108114
x={slotPosition[0]}
109115
y={slotPosition[1]}
110116
def={getModuleDef(selectedModuleModel)}
111117
orientation={orientation}
118+
targetDeckId={null}
119+
targetSlotId={null}
112120
>
113121
<>
114122
<SelectedModuleLabwareRender

shared-data/js/types.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -577,11 +577,15 @@ export interface ModuleDefinition {
577577
export type AffineTransformMatrix = number[][]
578578

579579
export interface SlotTransforms {
580-
[deckOtId: string]: {
581-
[slotId: string]: {
582-
[transformKey in keyof ModuleDefinition]?: AffineTransformMatrix
583-
}
584-
}
580+
[deckOtId: string]:
581+
| undefined
582+
| {
583+
[slotId: string]:
584+
| undefined
585+
| {
586+
[transformKey in keyof ModuleDefinition]?: AffineTransformMatrix
587+
}
588+
}
585589
}
586590

587591
export type ModuleOrientation = 'left' | 'right'

0 commit comments

Comments
 (0)