From 8072fa86dd33a7723d604816e78d93108f366765 Mon Sep 17 00:00:00 2001 From: Sumedha Pramod Date: Wed, 15 Nov 2017 10:08:07 -0800 Subject: [PATCH] Fix: Ensure newly created threads are set as inactive while saving (#38) * Fix: Ensure newly created threads are set as inactive while saving * Fix: Ordering of event bindings --- src/AnnotationThread.js | 1 + src/CommentBox.js | 11 +++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/AnnotationThread.js b/src/AnnotationThread.js index 73ca7c076..5d0f66eec 100644 --- a/src/AnnotationThread.js +++ b/src/AnnotationThread.js @@ -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 diff --git a/src/CommentBox.js b/src/CommentBox.js index dca0f64c3..b9bc8905b 100644 --- a/src/CommentBox.js +++ b/src/CommentBox.js @@ -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); } /** @@ -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));