Skip to content

Commit

Permalink
Fix: Passing event into thread.mouseoutHandler() (#375)
Browse files Browse the repository at this point in the history
  • Loading branch information
pramodsum authored Sep 8, 2017
1 parent fe15754 commit 2fe3c37
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/lib/annotations/AnnotationThread.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,14 @@ class AnnotationThread extends EventEmitter {
* Mouseout handler. Hides dialog if we aren't creating the first one.
*
* @private
* @param {HTMLEvent} event - DOM event
* @return {void}
*/
mouseoutHandler() {
mouseoutHandler(event) {
if (!event) {
return;
}

const mouseInDialog = annotatorUtil.isInDialog(event, this.dialog.element);

if (this.annotations.length !== 0 && !mouseInDialog) {
Expand Down
10 changes: 8 additions & 2 deletions src/lib/annotations/__tests__/AnnotationThread-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -608,9 +608,15 @@ describe('lib/annotations/AnnotationThread', () => {
});

describe('mouseoutHandler()', () => {
it('should do nothing if event does not exist', () => {
stubs.isInDialog = sandbox.stub(annotatorUtil, 'isInDialog');
thread.mouseoutHandler();
expect(stubs.isInDialog).to.not.be.called;
});

it('should not call hideDialog if there are no annotations in the thread', () => {
stubs.hide = sandbox.stub(thread, 'hideDialog');
thread.mouseoutHandler();
thread.mouseoutHandler({});
expect(stubs.hide).to.not.be.called;
});

Expand All @@ -627,7 +633,7 @@ describe('lib/annotations/AnnotationThread', () => {
});

thread.annotations = [annotation];
thread.mouseoutHandler();
thread.mouseoutHandler({});
expect(stubs.hide).to.be.called;
});
});
Expand Down

0 comments on commit 2fe3c37

Please sign in to comment.