diff --git a/src/controllers/DrawingModeController.js b/src/controllers/DrawingModeController.js index 92ec283c3..438b17305 100644 --- a/src/controllers/DrawingModeController.js +++ b/src/controllers/DrawingModeController.js @@ -324,7 +324,7 @@ class DrawingModeController extends AnnotationModeController { } const location = this.annotator.getLocationFromEvent(event, TYPES.point); - if (!location) { + if (!location || Object.keys(this.threads).length === 0) { return; } diff --git a/src/controllers/__tests__/DrawingModeController-test.js b/src/controllers/__tests__/DrawingModeController-test.js index 56ed3c3be..b0546e443 100644 --- a/src/controllers/__tests__/DrawingModeController-test.js +++ b/src/controllers/__tests__/DrawingModeController-test.js @@ -410,6 +410,18 @@ describe('controllers/DrawingModeController', () => { expect(stubs.clean).to.not.be.called; }); + it('should do nothing if no drawing threads exist', () => { + stubs.clean = sandbox.stub(controller, 'removeSelection'); + stubs.getLoc.returns({ + x: 15, + y: 15, + page: 1 + }); + controller.threads = {}; + controller.handleSelection('event'); + expect(stubs.clean).to.not.be.called; + }); + it('should call select on an thread found in the data store', () => { stubs.select = sandbox.stub(controller, 'select'); stubs.clean = sandbox.stub(controller, 'removeSelection');