Skip to content

Commit

Permalink
fix(nodes): find all edges when node has multiple handles
Browse files Browse the repository at this point in the history
  • Loading branch information
moklick committed Oct 4, 2019
1 parent 0bd2102 commit 35fa292
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/graph-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,15 @@ export const getNodesInside = (nodes, bbox, transform = [0, 0, 1], partially = f

export const getConnectedEdges = (nodes, edges) => {
const nodeIds = nodes.map(n => n.id);
return edges.filter(e => nodeIds.includes(e.source) || nodeIds.includes(e.target));
return edges.filter(e => {
const hasSourceHandleId = e.source.includes('__');
const hasTargetHandleId = e.target.includes('__');

const sourceId = hasSourceHandleId ? e.source.split('__')[0] : e.source;
const targetId = hasTargetHandleId ? e.target.split('__')[0] : e.target;

return nodeIds.includes(sourceId) || nodeIds.includes(targetId);
});
};

export const fitView = ({ padding = 0 } = {}) => {
Expand Down

0 comments on commit 35fa292

Please sign in to comment.