diff --git a/src/lib/annotations/AnnotationDialog.js b/src/lib/annotations/AnnotationDialog.js index a10567395..7ee9e2c8e 100644 --- a/src/lib/annotations/AnnotationDialog.js +++ b/src/lib/annotations/AnnotationDialog.js @@ -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); diff --git a/src/lib/annotations/doc/DocHighlightDialog.js b/src/lib/annotations/doc/DocHighlightDialog.js index bdb78fefc..4232859ef 100644 --- a/src/lib/annotations/doc/DocHighlightDialog.js +++ b/src/lib/annotations/doc/DocHighlightDialog.js @@ -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); diff --git a/src/lib/annotations/doc/__tests__/DocHighlightDialog-test.js b/src/lib/annotations/doc/__tests__/DocHighlightDialog-test.js index ba24250aa..f8fd44921 100644 --- a/src/lib/annotations/doc/__tests__/DocHighlightDialog-test.js +++ b/src/lib/annotations/doc/__tests__/DocHighlightDialog-test.js @@ -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); });