Skip to content

Commit

Permalink
fix position reference (#298)
Browse files Browse the repository at this point in the history
* fix pos reference

* spread annotations
  • Loading branch information
roppazvan authored Jun 18, 2024
1 parent 20242b4 commit 389b17a
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions packages/graph-editor/src/editor/actions/duplicate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,23 @@ export const duplicateNodes = ({ graph, reactFlowInstance, nodeLookup }: IDuplic
}
const newID = uuidv4();
const saved = graphNode.serialize();
const newPosition = {
x: node.position.x + 20,
y: node.position.y + 100,
}

const newGraphNode = graphNode?.factory.deserialize({
serialized: {
...saved,
id: newID,
annotations: {
...saved.annotations,
'ui.position.x': newPosition.x,
'ui.position.y': newPosition.y,
}
},
graph,
lookup: nodeLookup
lookup: nodeLookup,
}
);

Expand Down Expand Up @@ -71,10 +80,7 @@ export const duplicateNodes = ({ graph, reactFlowInstance, nodeLookup }: IDuplic
...node,
id: newID,
selected: true,
position: {
x: node.position.x + 20,
y: node.position.y + 100,
},
position: newPosition,
}];


Expand Down

0 comments on commit 389b17a

Please sign in to comment.