From c5861b3b9efee629d5e12d7f476514963ffc0c9d Mon Sep 17 00:00:00 2001 From: Jethary Date: Fri, 16 Feb 2024 09:29:36 -0500 Subject: [PATCH] another fix to draggableStepItems --- .../steplist/DraggableStepItems.tsx | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/protocol-designer/src/components/steplist/DraggableStepItems.tsx b/protocol-designer/src/components/steplist/DraggableStepItems.tsx index 3d21a493ea9..821712ba28f 100644 --- a/protocol-designer/src/components/steplist/DraggableStepItems.tsx +++ b/protocol-designer/src/components/steplist/DraggableStepItems.tsx @@ -108,22 +108,19 @@ export const DraggableStepItems = ( const findStepIndex = (stepId: StepIdType): number => stepIds.findIndex(id => stepId === id) - const moveStep = React.useCallback( - (stepId: StepIdType, targetIndex: number): void => { - const currentIndex = findStepIndex(stepId) - const currentRemoved = [ - ...stepIds.slice(0, currentIndex), - ...stepIds.slice(currentIndex + 1, stepIds.length), - ] - const currentReinserted = [ - ...currentRemoved.slice(0, targetIndex), - stepId, - ...currentRemoved.slice(targetIndex, currentRemoved.length), - ] - setStepIds(currentReinserted) - }, - [stepIds, findStepIndex] - ) + const moveStep = (stepId: StepIdType, targetIndex: number): void => { + const currentIndex = findStepIndex(stepId) + const currentRemoved = [ + ...stepIds.slice(0, currentIndex), + ...stepIds.slice(currentIndex + 1, stepIds.length), + ] + const currentReinserted = [ + ...currentRemoved.slice(0, targetIndex), + stepId, + ...currentRemoved.slice(targetIndex, currentRemoved.length), + ] + setStepIds(currentReinserted) + } const currentIds = isOver ? stepIds : orderedStepIds