diff --git a/src/doc/DocAnnotator.js b/src/doc/DocAnnotator.js index 00b1baad9..d930780a7 100644 --- a/src/doc/DocAnnotator.js +++ b/src/doc/DocAnnotator.js @@ -363,12 +363,13 @@ class DocAnnotator extends Annotator { * @return {void} */ setupAnnotations() { - super.setupAnnotations(); - + // Determine enabled annotation types before binding mode controller listeners this.plainHighlightEnabled = !!this.modeControllers[TYPES.highlight]; this.commentHighlightEnabled = !!this.modeControllers[TYPES.highlight_comment]; this.drawEnabled = !!this.modeControllers[TYPES.draw]; + super.setupAnnotations(); + // Don't bind to draw specific handlers if we cannot draw if (this.drawEnabled) { this.drawingSelectionHandler = this.drawingSelectionHandler.bind(this); @@ -519,7 +520,7 @@ class DocAnnotator extends Annotator { return null; } - if (this.createHighlightDialog && this.createHighlightDialog.isVisble) { + if (this.createHighlightDialog && this.createHighlightDialog.isVisible) { this.createHighlightDialog.hide(); } @@ -590,7 +591,7 @@ class DocAnnotator extends Annotator { return; } - if (!this.createHighlightDialog.isVisble) { + if (!this.createHighlightDialog.isVisible) { this.createHighlightDialog.show(this.container); } diff --git a/src/doc/__tests__/DocAnnotator-test.js b/src/doc/__tests__/DocAnnotator-test.js index fd17d3f71..b1b509e30 100644 --- a/src/doc/__tests__/DocAnnotator-test.js +++ b/src/doc/__tests__/DocAnnotator-test.js @@ -92,7 +92,7 @@ describe('doc/DocAnnotator', () => { destroy: () => {}, show: () => {}, hide: () => {}, - setPosition: () => {} + setPosition: () => {}, }; stubs.createDialogMock = sandbox.mock(annotator.createHighlightDialog); }); @@ -428,6 +428,13 @@ describe('doc/DocAnnotator', () => { annotator.createHighlightThread(''); }); + it('should hide the dialog if it exists and is visible', () => { + annotator.lastHighlightEvent = {}; + annotator.createHighlightDialog.isVisible = true; + stubs.createDialogMock.expects('hide').once(); + annotator.createHighlightThread('some text'); + }); + it('should do nothing and return null if there was no highlight event on the previous action', () => { annotator.lastHighlightEvent = null; stubs.createDialogMock.expects('hide').never();