Skip to content

Commit

Permalink
fix(context-pad): do not call triggerEntry twice when handling hover
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme committed Apr 29, 2024
1 parent 94a2d89 commit bc6ee49
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/features/context-pad/ContextPad.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ ContextPad.prototype.trigger = function(action, event, autoActivate) {
this._timeout = setTimeout(() => {
this._mouseout = this.triggerEntry(entry, 'hover', originalEvent, autoActivate);
}, HOVER_DELAY);

return;
} else if (action === 'mouseout') {
clearTimeout(this._timeout);

Expand All @@ -245,6 +247,8 @@ ContextPad.prototype.trigger = function(action, event, autoActivate) {

this._mouseout = null;
}

return;
}

return this.triggerEntry(entry, action, originalEvent, autoActivate);
Expand Down
12 changes: 12 additions & 0 deletions test/spec/features/context-pad/ContextPadSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -828,15 +828,21 @@ describe('features/context-pad', function() {

var event = globalEvent(target, { x: 0, y: 0 });

sinon.spy(contextPad, 'triggerEntry');

// when
contextPad.trigger('mouseover', event);

expect(event.__handled).not.to.exist;

expect(contextPad.triggerEntry).not.to.have.been.called;

clock.tick(500);

// then
expect(event.__handled).to.be.true;

expect(contextPad.triggerEntry).to.have.been.calledOnceWith('action.hover', 'hover', event);
}));


Expand Down Expand Up @@ -865,11 +871,15 @@ describe('features/context-pad', function() {

var event = globalEvent(target, { x: 0, y: 0 });

sinon.spy(contextPad, 'triggerEntry');

// when
contextPad.trigger('mouseover', event);

expect(event.__handled).not.to.exist;

expect(contextPad.triggerEntry).not.to.have.been.called;

clock.tick(250);

contextPad.trigger('click', globalEvent(target, { x: 0, y: 0 }));
Expand All @@ -878,6 +888,8 @@ describe('features/context-pad', function() {

// then
expect(event.__handled).not.to.exist;

expect(contextPad.triggerEntry).not.to.have.been.calledWith('action.hover', 'hover', event);
}));


Expand Down

0 comments on commit bc6ee49

Please sign in to comment.