diff --git a/protocol-designer/src/pages/Designer/DeckSetup/DeckSetupTools.tsx b/protocol-designer/src/pages/Designer/DeckSetup/DeckSetupTools.tsx
index 62a5f92d46e..44732c1e0ed 100644
--- a/protocol-designer/src/pages/Designer/DeckSetup/DeckSetupTools.tsx
+++ b/protocol-designer/src/pages/Designer/DeckSetup/DeckSetupTools.tsx
@@ -18,6 +18,7 @@ import {
} from '@opentrons/components'
import {
FLEX_ROBOT_TYPE,
+ FLEX_STAGING_AREA_SLOT_ADDRESSABLE_AREAS,
getModuleDisplayName,
getModuleType,
MAGNETIC_MODULE_TYPE,
@@ -58,7 +59,7 @@ import { LabwareTools } from './LabwareTools'
import { MagnetModuleChangeContent } from './MagnetModuleChangeContent'
import { getModuleModelsBySlot, getDeckErrors } from './utils'
-import type { ModuleModel } from '@opentrons/shared-data'
+import type { AddressableAreaName, ModuleModel } from '@opentrons/shared-data'
import type { ThunkDispatch } from '../../../types'
import type { Fixture } from './constants'
@@ -242,7 +243,7 @@ export function DeckSetupTools(props: DeckSetupToolsProps): JSX.Element | null {
handleResetSearchTerm()
}
- const handleClear = (): void => {
+ const handleClear = (keepExistingLabware = false): void => {
onDeckProps?.setHoveredModule(null)
onDeckProps?.setHoveredFixture(null)
if (slot !== 'offDeck') {
@@ -250,31 +251,41 @@ export function DeckSetupTools(props: DeckSetupToolsProps): JSX.Element | null {
if (createdModuleForSlot != null) {
dispatch(deleteModule(createdModuleForSlot.id))
}
- // clear fixture(s) from slot
- if (createFixtureForSlots != null && createFixtureForSlots.length > 0) {
- createFixtureForSlots.forEach(fixture =>
- dispatch(deleteDeckFixture(fixture.id))
- )
- }
// clear labware from slot
if (
createdLabwareForSlot != null &&
- createdLabwareForSlot.labwareDefURI !== selectedLabwareDefUri
+ (!keepExistingLabware ||
+ createdLabwareForSlot.labwareDefURI !== selectedLabwareDefUri)
) {
dispatch(deleteContainer({ labwareId: createdLabwareForSlot.id }))
}
// clear nested labware from slot
if (
createdNestedLabwareForSlot != null &&
- createdNestedLabwareForSlot.labwareDefURI !==
- selectedNestedLabwareDefUri
+ (!keepExistingLabware ||
+ createdNestedLabwareForSlot.labwareDefURI !==
+ selectedNestedLabwareDefUri)
) {
dispatch(deleteContainer({ labwareId: createdNestedLabwareForSlot.id }))
}
// clear labware on staging area 4th column slot
- if (matchingLabwareFor4thColumn != null) {
+ if (matchingLabwareFor4thColumn != null && !keepExistingLabware) {
dispatch(deleteContainer({ labwareId: matchingLabwareFor4thColumn.id }))
}
+ // clear fixture(s) from slot
+ if (createFixtureForSlots != null && createFixtureForSlots.length > 0) {
+ createFixtureForSlots.forEach(fixture =>
+ dispatch(deleteDeckFixture(fixture.id))
+ )
+ // zoom out if you're clearing a staging area slot directly from a 4th column
+ if (
+ FLEX_STAGING_AREA_SLOT_ADDRESSABLE_AREAS.includes(
+ slot as AddressableAreaName
+ )
+ ) {
+ dispatch(selectZoomedIntoSlot({ slot: null, cutout: null }))
+ }
+ }
}
handleResetToolbox()
handleResetLabwareTools()
@@ -285,7 +296,7 @@ export function DeckSetupTools(props: DeckSetupToolsProps): JSX.Element | null {
}
const handleConfirm = (): void => {
// clear entities first before recreating them
- handleClear()
+ handleClear(true)
if (selectedFixture != null && cutout != null) {
// create fixture(s)
diff --git a/protocol-designer/src/pages/Designer/DeckSetup/SlotOverflowMenu.tsx b/protocol-designer/src/pages/Designer/DeckSetup/SlotOverflowMenu.tsx
index 8cc15363ea6..c6c37c5be31 100644
--- a/protocol-designer/src/pages/Designer/DeckSetup/SlotOverflowMenu.tsx
+++ b/protocol-designer/src/pages/Designer/DeckSetup/SlotOverflowMenu.tsx
@@ -15,6 +15,12 @@ import {
StyledText,
useOnClickOutside,
} from '@opentrons/components'
+import {
+ FLEX_ROBOT_TYPE,
+ FLEX_STAGING_AREA_SLOT_ADDRESSABLE_AREAS,
+ getCutoutIdFromAddressableArea,
+ getDeckDefFromRobotType,
+} from '@opentrons/shared-data'
import { getDeckSetupForActiveItem } from '../../../top-selectors/labware-locations'
import { deleteModule } from '../../../step-forms/actions'
@@ -32,10 +38,12 @@ import { getStagingAreaAddressableAreas } from '../../../utils'
import { selectors as labwareIngredSelectors } from '../../../labware-ingred/selectors'
import type { MouseEvent, SetStateAction } from 'react'
import type {
+ AddressableAreaName,
CoordinateTuple,
CutoutId,
DeckSlotId,
} from '@opentrons/shared-data'
+
import type { LabwareOnDeck } from '../../../step-forms'
import type { ThunkDispatch } from '../../../types'
@@ -146,6 +154,10 @@ export function SlotOverflowMenu(
const hasNoItems =
moduleOnSlot == null && labwareOnSlot == null && fixturesOnSlot.length === 0
+ const isStagingSlot = FLEX_STAGING_AREA_SLOT_ADDRESSABLE_AREAS.includes(
+ location as AddressableAreaName
+ )
+
const handleClear = (): void => {
// clear module from slot
if (moduleOnSlot != null) {
@@ -167,6 +179,21 @@ export function SlotOverflowMenu(
if (matchingLabware != null) {
dispatch(deleteContainer({ labwareId: matchingLabware.id }))
}
+ // delete staging slot if addressable area is on staging slot
+ if (isStagingSlot) {
+ const deckDef = getDeckDefFromRobotType(FLEX_ROBOT_TYPE)
+ const cutoutId = getCutoutIdFromAddressableArea(location, deckDef)
+ const stagingAreaEquipmentId = Object.values(
+ additionalEquipmentOnDeck
+ ).find(({ location }) => location === cutoutId)?.id
+ if (stagingAreaEquipmentId != null) {
+ dispatch(deleteDeckFixture(stagingAreaEquipmentId))
+ } else {
+ console.error(
+ `could not find equipment id for entity in ${location} with cutout id ${cutoutId}`
+ )
+ }
+ }
}
const showDuplicateBtn =
@@ -303,7 +330,7 @@ export function SlotOverflowMenu(
) : null}