Skip to content

Commit

Permalink
fix issue with swapping labware
Browse files Browse the repository at this point in the history
  • Loading branch information
jerader committed Feb 20, 2024
1 parent 7cbc731 commit e300361
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const AdapterControls = (
}
},
hover: () => {
if (handleDragHover) {
if (handleDragHover != null) {
handleDragHover()

Check warning on line 100 in protocol-designer/src/components/DeckSetup/LabwareOverlays/AdapterControls.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/components/DeckSetup/LabwareOverlays/AdapterControls.tsx#L100

Added line #L100 was not covered by tests
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,10 @@ export const EditLabware = (props: Props): JSX.Element | null => {
dispatch(openIngredientSelector(labwareOnDeck.id))

Check warning on line 52 in protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx#L51-L52

Added lines #L51 - L52 were not covered by tests
}

const [, drag] = useDrag(() => ({
const [, drag] = useDrag({

Check warning on line 55 in protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx#L55

Added line #L55 was not covered by tests
type: DND_TYPES.LABWARE,
item: { labwareOnDeck },
beginDrag: () => {
setDraggedLabware(labwareOnDeck)
return { labwareOnDeck }
},
endDrag: () => {
setHoveredLabware(null)
setDraggedLabware(null)
},
}))
})

const [{ draggedLabware, isOver }, drop] = useDrop(() => ({

Check warning on line 60 in protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx#L60

Added line #L60 was not covered by tests
accept: DND_TYPES.LABWARE,
Expand All @@ -82,8 +74,10 @@ export const EditLabware = (props: Props): JSX.Element | null => {
}
},

hover: () => {
setHoveredLabware(labwareOnDeck)
hover: (item: DroppedItem, monitor: DropTargetMonitor) => {
if (monitor.canDrop()) {
setHoveredLabware(labwareOnDeck)

Check warning on line 79 in protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx#L79

Added line #L79 was not covered by tests
}
},
collect: (monitor: DropTargetMonitor) => ({

Check warning on line 82 in protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx#L82

Added line #L82 was not covered by tests
isOver: monitor.isOver(),
Expand All @@ -98,6 +92,10 @@ export const EditLabware = (props: Props): JSX.Element | null => {
React.useEffect(() => {

Check warning on line 92 in protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx#L92

Added line #L92 was not covered by tests
if (draggedItem != null) {
setSlot(draggedItem.slot)
setDraggedLabware(draggedItem)

Check warning on line 95 in protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx#L94-L95

Added lines #L94 - L95 were not covered by tests
} else {
setHoveredLabware(null)
setDraggedLabware(null)

Check warning on line 98 in protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx#L97-L98

Added lines #L97 - L98 were not covered by tests
}
})

Expand Down

0 comments on commit e300361

Please sign in to comment.