Auto repositioning a node if the target relationship isn't valid (Org Chart)

Hi there,

working on a prototype heavily inspired by the Org Chart sample → GoJS/orgChartEditor.html at master · NorthwoodsSoftware/GoJS · GitHub

I’ve linked line #210 because in our prototype, if the relationship isn’t valid (not a parent), but the user triggers a mouseUp, we would like the Node to animate back to where it was.

Are there any good pointers on how to achieve this?

Try inserting at line 218:

  } else {
    diagram.layoutDiagram(true);

Thanks for help. layoutDiagram is good!

But simply placing it on line #218 doesn’t quite work because that handler is in the context of the mouseDrop event which only triggers when dropping on another node/object.

Have https://gojs.net/latest/api/symbols/Diagram.html#mouseDrop also call Diagram.layoutDiagram.

Hmmm, and mouseDrop on your link template should call it too, in case the user drops on a link.

I ended up getting this working with the tips above. TYVM.