Skip to content

Commit

Permalink
Fix onHover event not being triggered (chartjs#4297)
Browse files Browse the repository at this point in the history
Fix onHover event not being triggered

The core controller was looking at the wrong object (options.hover) to
find the function to be called on hover. The function is provided on the
top level options object (options.onHover).

By using the helper function, there's no need to verify if the callback
is defined, as the helper already does that.

Fixes chartjs#4296
  • Loading branch information
Ricardo Costa authored and etimberg committed May 28, 2017
1 parent d43a048 commit 9638c46
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/core/core.controller.js
Expand Up @@ -808,11 +808,9 @@ module.exports = function(Chart) {
me.active = me.getElementsAtEventForMode(e, hoverOptions.mode, hoverOptions);
}

// On Hover hook
if (hoverOptions.onHover) {
// Need to call with native event here to not break backwards compatibility
hoverOptions.onHover.call(me, e.native, me.active);
}
// Invoke onHover hook
// Need to call with native event here to not break backwards compatibility
helpers.callback(options.onHover || options.hover.onHover, [e.native, me.active], me);

if (e.type === 'mouseup' || e.type === 'click') {
if (options.onClick) {
Expand Down

0 comments on commit 9638c46

Please sign in to comment.