Skip to content

Commit

Permalink
Chore: Don't allow selection of saved thread in draw mode (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
pramodsum authored Mar 19, 2018
1 parent cf69943 commit b0afeb4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/controllers/DrawingModeController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

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

0 comments on commit b0afeb4

Please sign in to comment.