From c1b92750837f77030b1678716bbd9ef1eee1c492 Mon Sep 17 00:00:00 2001 From: Michal Srb Date: Mon, 29 Nov 2021 08:38:49 +0100 Subject: [PATCH] Fix bug in updateNodePosDiff action This is the intended logic. Without it triggering this action with a node id will always move selected nodes, which is not desirable if we want to move just an unselected node. The bug doesn't show up in current examples because at the moment either one selected node is moved or all the selected nodes are moved. TBH this should probably be changed to accept `ids` instead to handle the two cases instead of this tight coupling between the group selection code and this action. --- src/store/reducer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/store/reducer.ts b/src/store/reducer.ts index d9b9fbb4..db291f42 100644 --- a/src/store/reducer.ts +++ b/src/store/reducer.ts @@ -137,7 +137,7 @@ export default function reactFlowReducer(state = initialState, action: ReactFlow const { id, diff, isDragging } = action.payload; const nextNodes = state.nodes.map((node) => { - if (id === node.id || state.selectedElements?.find((sNode) => sNode.id === node.id)) { + if (id === node.id || (id == null && state.selectedElements?.find((sNode) => sNode.id === node.id))) { const updatedNode = { ...node, __rf: {