Skip to content

Commit

Permalink
Fix: fix highlight selection and typos (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Press authored and pramodsum committed Nov 8, 2017
1 parent c7b678e commit ca54d5e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/doc/DocAnnotator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -590,7 +591,7 @@ class DocAnnotator extends Annotator {
return;
}

if (!this.createHighlightDialog.isVisble) {
if (!this.createHighlightDialog.isVisible) {
this.createHighlightDialog.show(this.container);
}

Expand Down
9 changes: 8 additions & 1 deletion src/doc/__tests__/DocAnnotator-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe('doc/DocAnnotator', () => {
destroy: () => {},
show: () => {},
hide: () => {},
setPosition: () => {}
setPosition: () => {},
};
stubs.createDialogMock = sandbox.mock(annotator.createHighlightDialog);
});
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit ca54d5e

Please sign in to comment.