Skip to content

Commit

Permalink
Chore: It works
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Holdstock committed Aug 2, 2017
1 parent c34b50d commit f426a2e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/lib/annotations/CommentBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,19 @@ class CommentBox extends EventEmitter {
this.textAreaEl.focus();
}

/**
* Unfocus the text box.
*
* @return {void}
*/
blur() {
if (!this.containerEl) {
return;
}

document.activeElement.blur();
}

/**
* Clear out the text box.
*
Expand Down
4 changes: 4 additions & 0 deletions src/lib/annotations/doc/CreateHighlightDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ class CreateHighlightDialog extends EventEmitter {
* @return {void}
*/
onHighlightClick(event) {
event.preventDefault();
event.stopPropagation();
this.emit(CreateEvents.plain);
}
Expand All @@ -242,6 +243,7 @@ class CreateHighlightDialog extends EventEmitter {
* @return {void}
*/
onCommentClick(event) {
event.preventDefault();
event.stopPropagation();
this.emit(CreateEvents.comment);

Expand All @@ -261,6 +263,7 @@ class CreateHighlightDialog extends EventEmitter {
onCommentPost(text) {
this.emit(CreateEvents.commentPost, text);
this.commentBox.clear();
this.commentBox.blur();
}

/**
Expand Down Expand Up @@ -345,6 +348,7 @@ class CreateHighlightDialog extends EventEmitter {
this.commentCreateEl.addEventListener('touchstart', this.stopPropagation);
this.highlightCreateEl.addEventListener('touchend', this.onHighlightClick);
this.commentCreateEl.addEventListener('touchend', this.onCommentClick);
highlightDialogEl.addEventListener('touchend', this.stopPropagation);
}

// Hide comment box, by default
Expand Down
8 changes: 6 additions & 2 deletions src/lib/annotations/doc/DocAnnotator.js
Original file line number Diff line number Diff line change
Expand Up @@ -497,10 +497,14 @@ class DocAnnotator extends Annotator {
* @return {void}
*/
onSelectionChange(event) {
// Do nothing if in a text area
if (document.activeElement.nodeName.toLowerCase() === 'textarea') {
return;
}
// Do nothing if the selection is empty
const selection = window.getSelection().toString();
const selection = window.getSelection();
// Bail if mid highlight and tapping on the screen
if (!selection) {
if (!docAnnotatorUtil.isValidSelection(selection)) {
this.lastSelection = null;
this.lastHighlightEvent = null;
this.createHighlightDialog.hide();
Expand Down

0 comments on commit f426a2e

Please sign in to comment.