@dev wrote:
For some reason, I'm seeing an error during deletion of an edge. Edges are not being deleted from the view when I override the the command handler, which caused me to add this code. The data appears to be in the model using the check, the error seems to be an RXJS type error. However, I'm not sure why I would have to do this, I would expect that the prototype call at the end would pass the delete command to the CommandHandler parent. Note that the selection of a node does work consistently, which doesn't manually remove data from the model. The selection and deletion of an edge sometimes works, most of the time doesn't.
This issue has prompted me to also ask what are the best practices for the situation below that show up in other usages of the diagram tool. Questions:
- Am I using containsLinkData correctly?
- I am determining if the selected object exists, and then qualifying it as type by looking for a field in the object's data. Is there a better way to do this?
- Is there a macro that detects any type of key delete request as opposed to ORing all the keystroke options?
I'm using the two types differentiation to remove data from local storage and remote storage.
core.js:1440 ERROR TypeError: Cannot read property 'next' of undefined at Q.removeLinkDataCollection (go.js:393) at sg.DiagramEditorComponent.diagram.commandHandler.doKeyDown (diagram-editor.component.ts:106)this.diagram.commandHandler.doKeyDown = () => {
const e = this.diagram.lastInput;
const cmd = this.diagram.commandHandler;if (e.key === 'Backspace' || e.key === 'Delete') { const object = e.diagram.selection.first(); if (object && object.data['item_node']) { console.log('Delete request node'); } else if (object) { console.log('Delete request - edge ' + JSON.stringify(object.data)); if ((this.diagram.model as go.GraphLinksModel).containsLinkData(object.data)) { (this.diagram.model as go.GraphLinksModel).removeLinkDataCollection(object.data);// LINE 106 WHERE ERROR IS } } go.CommandHandler.prototype.doKeyDown.call(cmd); }
Posts: 4
Participants: 2