Closed AndyEdmonds closed 3 years ago
Just to add to this, my implementation uses two layouts, "cose" and "dagre" this only happens with the "cose" layout.
Yet another update. Further investigation shows that the nodes that are selected in place of the original are those generated by the edgehandles project.
I have, what must be a common choice, cytoscape.min.js, cytoscape-cxtmenu.js, and cytoscape-edgehandles.js running in my application, with a couple of layouts. I was wrong previously: this defect occurs with all the layouts I have tried.
The bug I have found is that inside cxtmenu, the element passed to the selection function can be either the genuine node, or the transitory node generated by the edgehandles code to represent the starting point of an edge drawing process.
I would have thought that most implementers would have used these three cytoscape projects together, so it surprises me that this bug has not occurred before. Knowing more fully what has caused this gives me a chance to build a workaround - but I'm surprised one doesn't exist already.
See https://github.com/cytoscape/cytoscape.js-edgehandles/issues/143
If you're interested in contributing to this issue, you're welcome to create a pull request in the edgehandles repo.
I'm closing this issue, since it doesn't look like it's specific to the context menu.
All the best with your project.
Don't know if it still helps, but we found a workaround for this exact problem. https://github.com/cytoscape/cytoscape.js-edgehandles/issues/166#issuecomment-931268439
When right button clicking on a node I get the correct menu for a node, yet sometimes the element passed is for an unknown node. It appears that an empty node element is generated on the first right button click, located next to the selected node, and then subsequently that element is often returned rather than the correct node for subsequent menu selections.