Skip to content

Commit

Permalink
Fix: Get mode button from header element rather than container (#308)
Browse files Browse the repository at this point in the history
- This is a fix specifically for Annotations in the ContentPreview element or other cases when the header element is not contained inside box-content-preview
  • Loading branch information
pramodsum authored Dec 4, 2018
1 parent 734fc6c commit b50d72b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/controllers/AnnotationModeController.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class AnnotationModeController extends EventEmitter {
*/
getButton(annotatorSelector: string): HTMLElement {
// $FlowFixMe
return this.container.querySelector(annotatorSelector);
return this.headerElement.querySelector(annotatorSelector);
}

/**
Expand Down
8 changes: 2 additions & 6 deletions src/controllers/__tests__/AnnotationModeController-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,11 @@ describe('controllers/AnnotationModeController', () => {
it('should return the annotation mode button', () => {
const buttonEl = document.createElement('button');
buttonEl.classList.add('class');
controller.container = document.createElement('div');
controller.container.appendChild(buttonEl);
controller.headerElement = document.createElement('div');
controller.headerElement.appendChild(buttonEl);

expect(controller.getButton('.class')).not.toBeNull();
});

it('should return null if no headerElement', () => {
expect(controller.getButton('.class')).toBeNull();
});
});

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

0 comments on commit b50d72b

Please sign in to comment.