diff --git a/src/lib/viewers/BaseViewer.js b/src/lib/viewers/BaseViewer.js index 6308ae1d1..bbab51f35 100644 --- a/src/lib/viewers/BaseViewer.js +++ b/src/lib/viewers/BaseViewer.js @@ -722,6 +722,10 @@ class BaseViewer extends EventEmitter { * @return {boolean} Whether or not viewer is annotatable */ isAnnotatable(type) { + if (!this.annotatorConf) { + return false; + } + const { TYPE: annotationTypes } = this.annotatorConf; if (type && annotationTypes) { if (!annotationTypes.some((annotationType) => type === annotationType)) { diff --git a/src/lib/viewers/__tests__/BaseViewer-test.js b/src/lib/viewers/__tests__/BaseViewer-test.js index 3de92d51d..7acf547a2 100644 --- a/src/lib/viewers/__tests__/BaseViewer-test.js +++ b/src/lib/viewers/__tests__/BaseViewer-test.js @@ -806,6 +806,11 @@ describe('lib/viewers/BaseViewer', () => { sandbox.stub(base, 'areAnnotationsEnabled').returns(true); }); + it('should return false if annotations are not allowed on the current viewer', () => { + base.annotatorConf = undefined; + expect(base.isAnnotatable('point')).to.equal(false); + }) + it('should return true if the type is supported by the viewer', () => { expect(base.isAnnotatable('point')).to.equal(true); });