Skip to content

Commit f85f109

Browse files
committed
Fix select edit shape and nothing is active
If you right click an annotation and select edit shape and no annotation is active, there was a javascript error. This also fixes some issues if you turn off an annotation while editing it.
1 parent d6bd8bb commit f85f109

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

histomicsui/web_client/views/body/ImageView.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,7 +1431,9 @@ var ImageView = View.extend({
14311431

14321432
_editElementShape(element, annotationId) {
14331433
this._preeditDrawMode = this.drawWidget ? this.drawWidget.drawingType() : undefined;
1434-
this.drawWidget.cancelDrawMode();
1434+
if (this.drawWidget && this.drawWidget.drawingType()) {
1435+
this.drawWidget.cancelDrawMode();
1436+
}
14351437
const annotation = this.annotations.get(element.originalAnnotation || annotationId);
14361438
this._editAnnotation(annotation);
14371439
const geojson = convertToGeojson(element);
@@ -1584,6 +1586,12 @@ var ImageView = View.extend({
15841586
});
15851587
},
15861588
_deselectAnnotationElements(evt) {
1589+
if (this.viewerWidget && this.viewerWidget.annotationLayer && this.viewerWidget.annotationLayer.mode() !== null) {
1590+
if (this.drawWidget) {
1591+
this.drawWidget._drawingType = null;
1592+
}
1593+
this.viewerWidget.annotationLayer.mode(null);
1594+
}
15871595
const model = (evt || {}).model;
15881596
if (this.selectedElements && this.selectedElements.length) {
15891597
const elements = this.selectedElements.models.filter((el) => el.originalAnnotation.id === model.id);
@@ -1703,11 +1711,13 @@ var ImageView = View.extend({
17031711
},
17041712

17051713
_drawModeChange(evt) {
1706-
if (this._drawingType) {
1714+
if (this.drawWidget && this.drawWidget._drawingType) {
17071715
this.viewer.annotationLayer.mode(null);
17081716
this.viewer.annotationLayer.geoOff(geo.event.annotation.state);
17091717
}
1710-
this._drawingType = null;
1718+
if (this.drawWidget) {
1719+
this.drawWidget._drawingType = null;
1720+
}
17111721
$('#h-analysis-panel .input-group-btn').find('.s-select-region-button').removeClass('active');
17121722
},
17131723

0 commit comments

Comments
 (0)