Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/controllers/PointModeController.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,14 @@ class PointModeController extends AnnotationModeController {
// Get annotation location from click event, ignore click if location is invalid
const location = this.annotator.getLocationFromEvent(event, TYPES.point);
if (!location) {
this.hideSharedDialog();
return;
}

// Create new thread with no annotations, show indicator, and show dialog
const thread = this.annotator.createAnnotationThread([], location, TYPES.point);
if (!thread) {
this.hideSharedDialog();
return;
}

Expand Down
11 changes: 5 additions & 6 deletions src/controllers/__tests__/PointModeController-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ describe('controllers/PointModeController', () => {
beforeEach(() => {
stubs.destroy = sandbox.stub(controller, 'destroyPendingThreads');
sandbox.stub(controller, 'registerThread');
sandbox.stub(controller, 'hideSharedDialog');
controller.modeButton = {
title: 'Point Annotation Mode',
selector: '.bp-btn-annotate'
Expand All @@ -243,12 +244,6 @@ describe('controllers/PointModeController', () => {
expect(stubs.destroy).to.not.be.called;
});

it('should not destroy the pending thread if click was in the dialog', () => {
stubs.isInDialog.returns(true);
controller.pointClickHandler(event);
expect(stubs.destroy).to.not.be.called;
});

it('should reset the mobile annotations dialog if the user is on a mobile device', () => {
stubs.destroy.returns(false);
stubs.annotatorMock.expects('getLocationFromEvent');
Expand All @@ -266,6 +261,7 @@ describe('controllers/PointModeController', () => {

controller.pointClickHandler(event);
expect(controller.registerThread).to.not.be.called;
expect(controller.hideSharedDialog).to.be.called;
});

it('should not create a thread if a location object cannot be inferred from the event', () => {
Expand All @@ -276,6 +272,7 @@ describe('controllers/PointModeController', () => {

controller.pointClickHandler(event);
expect(controller.registerThread).to.not.be.called;
expect(controller.hideSharedDialog).to.be.called;
});

it('should create, show, and bind listeners to a thread', () => {
Expand All @@ -289,6 +286,7 @@ describe('controllers/PointModeController', () => {
expect(controller.registerThread).to.be.called;
expect(controller.emit).to.be.calledWith(THREAD_EVENT.pending, 'data');
expect(controller.registerThread).to.be.calledWith(stubs.thread);
expect(controller.hideSharedDialog).to.not.be.called;
});

it('should show the create dialog', () => {
Expand All @@ -310,6 +308,7 @@ describe('controllers/PointModeController', () => {
createMock.expects('showCommentBox');

controller.pointClickHandler(event);
expect(controller.hideSharedDialog).to.not.be.called;
});
});
});