diff --git a/src/controllers/DrawingModeController.js b/src/controllers/DrawingModeController.js index 0675e9646..cb8c49e4c 100644 --- a/src/controllers/DrawingModeController.js +++ b/src/controllers/DrawingModeController.js @@ -221,7 +221,8 @@ class DrawingModeController extends AnnotationModeController { */ handleSelection(event) { // NOTE: @jpress This is a workaround when buttons are not given precedence in the event chain - if (!event || (event.target && event.target.nodeName === 'BUTTON')) { + const hasPendingDrawing = this.currentThread && this.currentThread.state === STATES.pending; + if (!event || (event.target && event.target.nodeName === 'BUTTON') || hasPendingDrawing) { return; } diff --git a/src/controllers/__tests__/DrawingModeController-test.js b/src/controllers/__tests__/DrawingModeController-test.js index 9d828df32..b148fcb92 100644 --- a/src/controllers/__tests__/DrawingModeController-test.js +++ b/src/controllers/__tests__/DrawingModeController-test.js @@ -4,6 +4,7 @@ import DrawingModeController from '../DrawingModeController'; import * as util from '../../util'; import { TYPES, + STATES, THREAD_EVENT, SELECTOR_ANNOTATION_BUTTON_DRAW_CANCEL, SELECTOR_ANNOTATION_BUTTON_DRAW_POST, @@ -355,6 +356,12 @@ describe('controllers/DrawingModeController', () => { expect(stubs.event.stopPropagation).to.be.called; }); + it('should do nothing with while drawing a new annotation event', () => { + controller.currentThread = { state: STATES.pending }; + controller.handleSelection(stubs.event); + expect(stubs.intersecting).to.not.be.called; + }) + it('should call select on an thread found in the data store', () => { controller.handleSelection(stubs.event); expect(stubs.clean).to.be.called;