Skip to content

Commit

Permalink
Fix: Prevent creation of highlights when a point annotation is pending (
Browse files Browse the repository at this point in the history
  • Loading branch information
pramodsum authored Nov 20, 2017
1 parent 10c1c98 commit 42e29ce
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/doc/DocAnnotator.js
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,12 @@ class DocAnnotator extends Annotator {

this.isCreatingHighlight = false;

// Prevent the creation of highlights if the user is currently creating a point annotation
const pointController = this.modeControllers[TYPES.point];
if (pointController && pointController.hadPendingThreads) {
return;
}

// Creating highlights is disabled on mobile for now since the
// event we would listen to, selectionchange, fires continuously and
// is unreliable. If the mouse moved or we double clicked text,
Expand Down
10 changes: 10 additions & 0 deletions src/doc/__tests__/DocAnnotator-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,16 @@ describe('doc/DocAnnotator', () => {
stubs.click = sandbox.stub(annotator, 'highlightClickHandler');
});

it('should not trigger a highlight or creation if a point annotation is pending', () => {
annotator.modeControllers = {
'point': { hadPendingThreads: true }
};
annotator.highlightMouseupHandler({});
expect(stubs.create).to.not.be.called;
expect(stubs.click).to.not.be.called;
expect(annotator.isCreatingHighlight).to.be.false;
})

it('should call highlightCreateHandler if not on mobile, and the user double clicked', () => {
annotator.highlightMouseupHandler({ type: 'dblclick' });
expect(stubs.create).to.be.called;
Expand Down

0 comments on commit 42e29ce

Please sign in to comment.