From 0b747174b359be0812222623470977d6cf02b5d0 Mon Sep 17 00:00:00 2001 From: Sumedha Pramod Date: Tue, 14 Nov 2017 08:57:20 -0800 Subject: [PATCH] Fix: Hide createHighlightDialog on page re-render (#31) --- src/doc/DocAnnotator.js | 4 ++++ src/doc/__tests__/DocAnnotator-test.js | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/doc/DocAnnotator.js b/src/doc/DocAnnotator.js index 55182f5cd..6356041f1 100644 --- a/src/doc/DocAnnotator.js +++ b/src/doc/DocAnnotator.js @@ -331,6 +331,10 @@ class DocAnnotator extends Annotator { thread.destroy(); } }); + + if (this.createHighlightDialog && this.createHighlightDialog.isVisible) { + this.createHighlightDialog.hide(); + } } /** diff --git a/src/doc/__tests__/DocAnnotator-test.js b/src/doc/__tests__/DocAnnotator-test.js index f3aeb977b..ed6ebc847 100644 --- a/src/doc/__tests__/DocAnnotator-test.js +++ b/src/doc/__tests__/DocAnnotator-test.js @@ -584,6 +584,17 @@ describe('doc/DocAnnotator', () => { annotator.threads = {}; }); + + it('should clear and hide createHighlightDialog on page render', () => { + annotator.createHighlightDialog = { + isVisible: true, + hide: () => {}, + destroy: () => {} + }; + const createMock = sandbox.mock(annotator.createHighlightDialog); + createMock.expects('hide'); + annotator.renderAnnotationsOnPage(1); + }); }); describe('scaleAnnotationCanvases()', () => {