Skip to content

Commit

Permalink
Fix: Buttons fail to display when adding a comment to plain highlight (
Browse files Browse the repository at this point in the history
…#183)

- Ensures the post/cancel buttons for adding the first comment to a highlight dialog are never hidden
- Fixes a bug where the highlight annotations that had only 1 comment were being displayed as plain highlights
  • Loading branch information
pramodsum authored Jun 23, 2017
1 parent fc51f75 commit a344153
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/lib/annotations/AnnotationDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,9 @@ const CLASS_ANIMATE_DIALOG = 'bp-animate-show-dialog';
return;
}

const replyTextEl = this.dialogEl.querySelector(constants.SELECTOR_REPLY_TEXTAREA);
const replyButtonEls = this.dialogEl.querySelector(constants.SELECTOR_BUTTON_CONTAINER);
const replyContainerEl = this.dialogEl.querySelector(constants.SELECTOR_REPLY_CONTAINER);
const replyTextEl = replyContainerEl.querySelector(constants.SELECTOR_REPLY_TEXTAREA);
const replyButtonEls = replyContainerEl.querySelector(constants.SELECTOR_BUTTON_CONTAINER);
annotatorUtil.resetTextarea(replyTextEl, clearText);
annotatorUtil.hideElement(replyButtonEls);

Expand Down
2 changes: 1 addition & 1 deletion src/lib/annotations/doc/DocHighlightDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ const PAGE_PADDING_TOP = 15;
this.dialogEl = document.createElement('div');
this.dialogEl.appendChild(this.highlightDialogEl);
this.dialogEl.appendChild(this.commentsDialogEl);
if (annotations.length > 1) {
if (this.hasComments) {
this.highlightDialogEl.classList.add(CLASS_HIDDEN);
} else {
this.commentsDialogEl.classList.add(CLASS_HIDDEN);
Expand Down
19 changes: 15 additions & 4 deletions src/lib/annotations/doc/__tests__/DocHighlightDialog-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,24 @@ describe('lib/annotations/doc/DocHighlightDialog', () => {
expect(dialog.hasComments).to.be.false;
});

it('should hide the highlight dialog if thread has more than 1 annotation', () => {
dialog.setup([stubs.annotation, stubs.annotation]);
it('should hide the highlight dialog if thread has comments', () => {
dialog.hasComments = true;
dialog.setup([stubs.annotation]);
expect(dialog.highlightDialogEl).to.have.class(CLASS_HIDDEN);
});

it('should hide the comments dialog if thread only 1 annotation', () => {
dialog.setup([stubs.annotation]);
it('should hide the comments dialog if thread does not have comments', () => {
dialog.hasComments = false;
const annotation = new Annotation({
text: '',
user: { id: 1, name: 'Bob' },
permissions: {
can_delete: true
},
thread: 1
});

dialog.setup([annotation]);
expect(dialog.commentsDialogEl).to.have.class(CLASS_HIDDEN);
});

Expand Down

0 comments on commit a344153

Please sign in to comment.