fix: paste edges between components selected even if edges are not selected (#8497)

* Added pasting the edges between components selected as well

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
Lucas Oliveira 2025-06-12 14:55:49 -03:00 committed by GitHub
commit a913adc39f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -385,6 +385,21 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
track("Component Connection Deleted", { edgeId });
},
paste: (selection, position) => {
// Collect IDs of nodes in the selection
const selectedNodeIds = new Set(selection.nodes.map((node) => node.id));
// Find existing edges in the flow that connect nodes within the selection
const existingEdgesToCopy = get().edges.filter((edge) => {
return (
selectedNodeIds.has(edge.source) &&
selectedNodeIds.has(edge.target) &&
!selection.edges.some((selEdge) => selEdge.id === edge.id)
);
});
// Add these edges to the selection's edges
if (existingEdgesToCopy.length > 0) {
selection.edges = selection.edges.concat(existingEdgesToCopy);
}
if (
selection.nodes.some((node) => node.data.type === "ChatInput") &&
checkChatInput(get().nodes)