Bugfix: connections now properly removed when deleting attached annotation

This commit is contained in:
Rainer Simon 2020-04-29 11:36:52 +02:00
parent cc2421526e
commit 002af61add
2 changed files with 7 additions and 2 deletions

View File

@ -88,8 +88,7 @@ export default class TextAnnotator extends Component {
onDeleteAnnotation = annotation => { onDeleteAnnotation = annotation => {
// Delete connections // Delete connections
const connections = this.relationsLayer.getConnectionsFor(annotation); this.relationsLayer.destroyConnectionsFor(annotation);
connections.forEach(c => c.destroy());
this.clearState(); this.clearState();
this.selectionHandler.clearSelection(); this.selectionHandler.clearSelection();

View File

@ -104,6 +104,12 @@ export default class RelationsLayer extends EventEmitter {
c.startAnnotation.isEqual(annotation) || c.endAnnotation.isEqual(annotation)); 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 = () => show = () =>
this.svg.style.display = 'inital'; this.svg.style.display = 'inital';