Skip to content

Commit

Permalink
Fix: Ensure commentbox event listeners are bound properly (#37)
Browse files Browse the repository at this point in the history
* Fix: Create highlight dialog CSS styling
* Fix: Ensure commentbox event listeners are bound properly
  • Loading branch information
pramodsum committed Nov 15, 2017
1 parent 4199162 commit fcce638
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
9 changes: 9 additions & 0 deletions src/Annotator.scss
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,15 @@ $tablet: 'max-width: 768px';
}
}

.bp-create-annotation-dialog .bp-create-comment {
background-color: $white;
overflow-x: hidden;
overflow-y: auto;
padding: 9px;
white-space: normal;
width: 267px; // Hard-coded width to solve layout issues
}

.bp-point-annotation-marker {
background-color: transparent;
border-style: none;
Expand Down
11 changes: 8 additions & 3 deletions src/CommentBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ 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 @@ -271,10 +276,10 @@ class CommentBox extends EventEmitter {
// Add event listeners

if (this.hasTouch) {
this.textAreaEl.addEventListener('focus', this.focus.bind(this));
this.textAreaEl.addEventListener('focus', this.focus);
containerEl.addEventListener('touchend', this.preventDefaultAndPropagation.bind(this));
this.cancelEl.addEventListener('touchend', this.onCancel.bind(this));
this.postEl.addEventListener('touchend', this.onPost.bind(this));
this.cancelEl.addEventListener('touchend', this.onCancel);
this.postEl.addEventListener('touchend', this.onPost);
} else {
this.textAreaEl.addEventListener('focus', this.focus);
this.cancelEl.addEventListener('click', this.onCancel);
Expand Down

0 comments on commit fcce638

Please sign in to comment.