From 002af61add0033944749f19e43bcf248804491af Mon Sep 17 00:00:00 2001 From: Rainer Simon Date: Wed, 29 Apr 2020 11:36:52 +0200 Subject: [PATCH] Bugfix: connections now properly removed when deleting attached annotation --- src/TextAnnotator.jsx | 3 +-- src/relations/RelationsLayer.js | 6 ++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/TextAnnotator.jsx b/src/TextAnnotator.jsx index 197941f..edd8f85 100644 --- a/src/TextAnnotator.jsx +++ b/src/TextAnnotator.jsx @@ -88,8 +88,7 @@ export default class TextAnnotator extends Component { onDeleteAnnotation = annotation => { // Delete connections - const connections = this.relationsLayer.getConnectionsFor(annotation); - connections.forEach(c => c.destroy()); + this.relationsLayer.destroyConnectionsFor(annotation); this.clearState(); this.selectionHandler.clearSelection(); diff --git a/src/relations/RelationsLayer.js b/src/relations/RelationsLayer.js index d17a3f5..1ff5001 100644 --- a/src/relations/RelationsLayer.js +++ b/src/relations/RelationsLayer.js @@ -104,6 +104,12 @@ export default class RelationsLayer extends EventEmitter { c.startAnnotation.isEqual(annotation) || c.endAnnotation.isEqual(annotation)); } + destroyConnectionsFor = annotation => { + const connections = this.getConnectionsFor(annotation); + connections.forEach(c => c.destroy()); + this.connections = this.connections.filter(c => !connections.includes(c)); + } + show = () => this.svg.style.display = 'inital';