mirror of
https://github.com/AykutSarac/jsoncrack.com.git
synced 2025-01-27 15:22:56 +08:00
fix: don't show disconnected nodes on expand
This commit is contained in:
parent
0737bcbbbf
commit
f70af5806b
@ -43,7 +43,14 @@ const useGraph = create<Graph & GraphActions>((set, get) => ({
|
||||
);
|
||||
const childrenEdges = getChildrenEdges(childrenNodes, get().edges);
|
||||
|
||||
const nodeIds = childrenNodes.map(node => node.id).concat(matchingNodes);
|
||||
|
||||
let nodesConnectedToParent = childrenEdges.reduce((nodes: string[], edge) => {
|
||||
edge.from && !nodes.includes(edge.from) && nodes.push(edge.from)
|
||||
edge.to && !nodes.includes(edge.to) && nodes.push(edge.to)
|
||||
return nodes
|
||||
}, []);
|
||||
const matchingNodesConnectedToParent = matchingNodes.filter(node => nodesConnectedToParent.includes(node));
|
||||
const nodeIds = childrenNodes.map(node => node.id).concat(matchingNodesConnectedToParent);
|
||||
const edgeIds = childrenEdges.map(edge => edge.id);
|
||||
|
||||
const collapsedParents = get().collapsedParents.filter(cp => cp !== nodeId);
|
||||
|
Loading…
x
Reference in New Issue
Block a user