Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

link index property #98

Open
jonabox opened this issue Sep 20, 2021 · 0 comments
Open

link index property #98

jonabox opened this issue Sep 20, 2021 · 0 comments

Comments

@jonabox
Copy link

jonabox commented Sep 20, 2021

Hi, I'm trying to figure out where the .index property for links and nodes is generated. I'm trying to investigate why the code below removes the wrong link when I try to remove many links at a time:

removeLink (link) {
   this.unSelectLink(link.id);
   this.links.splice(link.index, 1);
}

and here's my full code, where removeLink is called:

for (let removedNodeId of serverResponse.data.nodesRemoved) {
        let edgeToRemove = this.links.findIndex(
          (edge) =>
            edge.sid == this.lastSelected.id && edge.tid == removedNodeId
        );
        this.removeLink(edgeToRemove);
}

The result is that the wrong link gets removed and I'm not sure why. I believe the culprit is the index property in the splice method, which might be getting overwritten when retrieved. But the question is, where is the .index property getting assigned? I haven't been able to find it in the codebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant