ProjectMirador / mirador-annotations

a Mirador 3 plugin that adds annotation creation tools to the user interface
https://mirador-annotations.netlify.app/
38 stars 37 forks source link

Annotations without target selector cannot be edited #46

Closed lutzhelm closed 3 years ago

lutzhelm commented 3 years ago

The plugin currently allows saving annotations without selecting a target region on the Canvas. This would be fine (I think), but the annotation can not be edited because an error occurs in the AnnotationCreation constructor.props.annotation.target.selector` is undefined in the following line:

https://github.com/ProjectMirador/mirador-annotations/blob/d6b55e038c80344fb0a3626d8a5b51475a645e29/src/AnnotationCreation.js#L62

I'd suggest to just put a check for props.annotation.target.selector around this block: https://github.com/ProjectMirador/mirador-annotations/blob/d6b55e038c80344fb0a3626d8a5b51475a645e29/src/AnnotationCreation.js#L53-L63

Alternatively, saving an annotation without a selector should not be allowed. But if an annotation store provides annotations from a different source than Mirador, the error might still occur.