Skip to content

Commit

Permalink
Fix: Uncaught errors in drawingModeController.handleSelection() (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
pramodsum committed Dec 20, 2017
1 parent 9fb674f commit 71926ed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/controllers/DrawingModeController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
12 changes: 12 additions & 0 deletions src/controllers/__tests__/DrawingModeController-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 71926ed

Please sign in to comment.