Skip to content

Commit

Permalink
fix(discoverability): set mode to REGION instead of NONE (#1260)
Browse files Browse the repository at this point in the history
* fix(discoverability): set mode to REGION instead of NONE

* feat(discoverability): revert initial changes

* feat(discoverability): call toggleAnnotationMode in handleFullscreenExit

* feat(discoverability): use parameterized test

* feat(discoverability): simplify logic

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
ChenCodes and mergify[bot] committed Sep 22, 2020
1 parent 6b4f76d commit 6ccbb55
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lib/viewers/BaseViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,9 @@ class BaseViewer extends EventEmitter {

if (this.annotator && this.areNewAnnotationsEnabled()) {
this.annotator.emit(ANNOTATOR_EVENT.setVisibility, true);
if (this.options.enableAnnotationsDiscoverability) {
this.annotator.toggleAnnotationMode(AnnotationMode.REGION);
}
this.enableAnnotationControls();
}
}
Expand Down
19 changes: 19 additions & 0 deletions src/lib/viewers/__tests__/BaseViewer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,25 @@ describe('lib/viewers/BaseViewer', () => {
expect(base.annotator.emit).to.be.calledWith(ANNOTATOR_EVENT.setVisibility, true);
expect(base.enableAnnotationControls).to.be.called;
});

it(`should show annotations and toggle annotations mode to REGION if enableAnnotationsDiscoverability is true`, () => {
sandbox.stub(base, 'areNewAnnotationsEnabled').returns(true);
sandbox.stub(base, 'enableAnnotationControls');
base.annotator = {
emit: sandbox.mock(),
toggleAnnotationMode: sandbox.mock(),
};
base.annotationControls = {
destroy: sandbox.mock(),
};
base.options.enableAnnotationsDiscoverability = true;

base.handleFullscreenExit();

expect(base.annotator.emit).to.be.calledWith(ANNOTATOR_EVENT.setVisibility, true);
expect(base.enableAnnotationControls).to.be.called;
expect(base.annotator.toggleAnnotationMode).to.be.calledWith(AnnotationMode.REGION);
});
});

describe('resize()', () => {
Expand Down

0 comments on commit 6ccbb55

Please sign in to comment.