Skip to content

Commit

Permalink
Fix: Ensure newly created threads are set as inactive while saving (#38
Browse files Browse the repository at this point in the history
)

* Fix: Ensure newly created threads are set as inactive while saving
* Fix: Ordering of event bindings
  • Loading branch information
pramodsum authored Nov 15, 2017
1 parent fcce638 commit 8072fa8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/AnnotationThread.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ class AnnotationThread extends EventEmitter {
tempAnnotationData.modified = tempAnnotationData.created;
const tempAnnotation = new Annotation(tempAnnotationData);
this.saveAnnotationToThread(tempAnnotation);
this.state = STATES.inactive;

// Save annotation on server
return this.annotationService
Expand Down
11 changes: 5 additions & 6 deletions src/CommentBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,6 @@ class CommentBox extends EventEmitter {
this.placeholderText = config.localized.addCommentPlaceholder;

this.containerEl = this.createCommentBox();

// Explicit scope binding for event listeners
this.focus = this.focus.bind(this);
this.onCancel = this.onCancel.bind(this);
this.onPost = this.onPost.bind(this);
}

/**
Expand Down Expand Up @@ -273,8 +268,12 @@ class CommentBox extends EventEmitter {
this.cancelEl = containerEl.querySelector(constants.SELECTOR_ANNOTATION_BUTTON_CANCEL);
this.postEl = containerEl.querySelector(constants.SELECTOR_ANNOTATION_BUTTON_POST);

// Add event listeners
// Explicit scope binding for event listeners
this.focus = this.focus.bind(this);
this.onCancel = this.onCancel.bind(this);
this.onPost = this.onPost.bind(this);

// Add event listeners
if (this.hasTouch) {
this.textAreaEl.addEventListener('focus', this.focus);
containerEl.addEventListener('touchend', this.preventDefaultAndPropagation.bind(this));
Expand Down

0 comments on commit 8072fa8

Please sign in to comment.