Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(protocol-designer): fix HighlightItems logic #17457

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
getSelectedDropdownItem,
} from '../../../ui/steps/selectors'
import { getDesignerTab } from '../../../file-data/selectors'
import { getIsAdapter } from '../../../utils'
import { LabwareLabel } from '../LabwareLabel'
import { ModuleLabel } from './ModuleLabel'
import { FixtureRender } from './FixtureRender'
Expand Down Expand Up @@ -75,10 +76,18 @@ export function HighlightItems(props: HighlightItemsProps): JSX.Element | null {
const selectedItemLabwares = selectedDropdownItems.filter(
selected => selected.id != null && labware[selected.id]
)

// if hovered item is an adapter, show bounding area for parent module
const isHoveredItemLabwareAdapter =
hoveredItemLabware?.id != null
? getIsAdapter(hoveredItemLabware?.id, labware)
: false
const moduleUnderLabware =
hoveredItemLabware != null ? modules[hoveredItemLabware?.slot] : null
const hoveredItemModule: ModuleOnDeck | null =
hoveredItem?.id != null && modules[hoveredItem.id] != null
? modules[hoveredItem.id]
: null
: moduleUnderLabware ?? null
const selectedItemModule = selectedDropdownItems.find(
selected => selected.id != null && modules[selected.id]
)
Expand All @@ -104,10 +113,17 @@ export function HighlightItems(props: HighlightItemsProps): JSX.Element | null {
selected.id != null && SLOTS.includes(selected.id as AddressableAreaName)
)

// show only module highlight or labware highlight, but not both
const showOnlyLabware =
moduleUnderLabware == null || !isHoveredItemLabwareAdapter

const getLabwareItems = (): JSX.Element[] => {
const items: JSX.Element[] = []

if (hoveredItemLabware != null || selectedItemLabwares.length > 0) {
if (
(hoveredItemLabware != null || selectedItemLabwares.length > 0) &&
showOnlyLabware
) {
const selectedLabwaresOnDeck = selectedItemLabwares
.map(item => (item?.id != null ? labware[item.id] : null))
.filter(Boolean)
Expand Down Expand Up @@ -179,7 +195,10 @@ export function HighlightItems(props: HighlightItemsProps): JSX.Element | null {
const getModuleItems = (): JSX.Element[] => {
const items: JSX.Element[] = []

if (hoveredItemModule != null || selectedItemModule != null) {
if (
(hoveredItemModule != null || selectedItemModule != null) &&
!showOnlyLabware
) {
const selectedModuleOnDeck =
selectedItemModule?.id != null ? modules[selectedItemModule.id] : null
const moduleOnDeck = hoveredItemModule ?? selectedModuleOnDeck
Expand Down
Loading