diff --git a/src/doc/DocAnnotator.js b/src/doc/DocAnnotator.js index a1fdb98a5..a7cee74ac 100644 --- a/src/doc/DocAnnotator.js +++ b/src/doc/DocAnnotator.js @@ -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, diff --git a/src/doc/__tests__/DocAnnotator-test.js b/src/doc/__tests__/DocAnnotator-test.js index 8b741fbef..449568a79 100644 --- a/src/doc/__tests__/DocAnnotator-test.js +++ b/src/doc/__tests__/DocAnnotator-test.js @@ -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;