react-diagrams icon indicating copy to clipboard operation
react-diagrams copied to clipboard

After deserialize problems (node and link loose its connection, unable to delete)

Open DanieLazarLDAPPS opened this issue 7 years ago • 0 comments

Hi,

I am facing issues after deserializing model back from a string. There are several issues:

  • Unable to delete: The entityRemove listener is not registered because it is not using .addNode or .addLink during deserialize ... It is using addModel of LinkModelLayer and NodeModelLayer. We should consider to move remove registration to addModel function
addModel(model: G['CHILDREN']): void {
	if (!(model instanceof LinkModel)) {
		throw new Error('Can only add links to this layer');
	}
	model.registerListener({
		entityRemoved: () => {
			(this.getParent() as DiagramModel).removeLink(model);
		}
	});
	super.addModel(model);
}
  • Port is not moving with the link in some conditions: This is linked with point 1. If link is going to be deleted the connection between node and link is lost but there is not entityRemove listener so link stays on its position and not removed. When the linked node is going to be moved after delete event link is not moving with it because delete event did his job only for source/target port. Screenshot from 2019-09-11 12-01-55

I think both issues are going to be fixed by registration entityRemoved as I proposed but I would like to check it because I don't know deep structure. @dylanvorster Do you think that there is a better place to register it during deserialize event?

DanieLazarLDAPPS avatar Sep 11 '19 10:09 DanieLazarLDAPPS