From b6371a06bcfcb0569a17d5b9f09b2419d3810719 Mon Sep 17 00:00:00 2001 From: Mingze Xiao Date: Thu, 5 Nov 2020 15:24:13 -0800 Subject: [PATCH] fix(annotations): Address comments --- src/lib/viewers/BaseViewer.js | 3 +-- src/lib/viewers/__tests__/BaseViewer-test.js | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/viewers/BaseViewer.js b/src/lib/viewers/BaseViewer.js index cabb59ef39..1a773d1c19 100644 --- a/src/lib/viewers/BaseViewer.js +++ b/src/lib/viewers/BaseViewer.js @@ -576,7 +576,6 @@ class BaseViewer extends EventEmitter { if (this.annotator && this.areNewAnnotationsEnabled()) { this.annotator.emit(ANNOTATOR_EVENT.setVisibility, false); this.disableAnnotationControls(); - this.processAnnotationModeChange(this.annotationControlsFSM.transition(AnnotationInput.RESET)); } } @@ -919,8 +918,8 @@ class BaseViewer extends EventEmitter { disableAnnotationControls() { if (this.annotator && this.annotationControls && this.areNewAnnotationsEnabled()) { this.annotator.toggleAnnotationMode(AnnotationMode.NONE); - this.annotationControls.resetControls(); this.annotationControls.toggle(false); + this.processAnnotationModeChange(this.annotationControlsFSM.transition(AnnotationInput.RESET)); } } diff --git a/src/lib/viewers/__tests__/BaseViewer-test.js b/src/lib/viewers/__tests__/BaseViewer-test.js index 321ea31f26..f450e0b599 100644 --- a/src/lib/viewers/__tests__/BaseViewer-test.js +++ b/src/lib/viewers/__tests__/BaseViewer-test.js @@ -1045,6 +1045,7 @@ describe('lib/viewers/BaseViewer', () => { describe('disableAnnotationControls()', () => { test('should hide annotations and toggle annotations mode', () => { jest.spyOn(base, 'areNewAnnotationsEnabled').mockReturnValue(true); + jest.spyOn(base, 'processAnnotationModeChange'); base.annotator = { toggleAnnotationMode: jest.fn(), @@ -1052,13 +1053,14 @@ describe('lib/viewers/BaseViewer', () => { base.annotationControls = { destroy: jest.fn(), resetControls: jest.fn(), + setMode: jest.fn(), toggle: jest.fn(), }; base.disableAnnotationControls(); - expect(base.annotationControls.resetControls).toBeCalled(); expect(base.annotationControls.toggle).toBeCalledWith(false); + expect(base.processAnnotationModeChange).toBeCalledWith(AnnotationMode.NONE); }); });