Skip to content

Commit

Permalink
Fix plugin event filtering of renamed events (#9613)
Browse files Browse the repository at this point in the history
  • Loading branch information
kurkle committed Sep 4, 2021
1 parent 8d68b11 commit 50ad163
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -61,7 +61,7 @@
"@vuepress/plugin-html-redirect": "^0.1.2",
"chartjs-adapter-luxon": "^1.0.0",
"chartjs-adapter-moment": "^1.0.0",
"chartjs-test-utils": "^0.3.0",
"chartjs-test-utils": "^0.3.1",
"concurrently": "^6.0.1",
"coveralls": "^3.1.0",
"cross-env": "^7.0.3",
Expand Down
2 changes: 1 addition & 1 deletion src/core/core.controller.js
Expand Up @@ -1067,7 +1067,7 @@ class Chart {
_eventHandler(e, replay) {
const me = this;
const args = {event: e, replay, cancelable: true};
const eventFilter = (plugin) => (plugin.options.events || this.options.events).includes(e.type);
const eventFilter = (plugin) => (plugin.options.events || this.options.events).includes(e.native.type);

if (me.notifyPlugins('beforeEvent', args, eventFilter) === false) {
return;
Expand Down
7 changes: 4 additions & 3 deletions test/specs/core.plugin.tests.js
Expand Up @@ -398,10 +398,10 @@ describe('Chart.plugins', function() {
const results = [];
const chart = window.acquireChart({
options: {
events: ['mousemove', 'test', 'test2'],
events: ['mousemove', 'test', 'test2', 'pointerleave'],
plugins: {
testPlugin: {
events: ['test']
events: ['test', 'pointerleave']
}
}
},
Expand All @@ -418,7 +418,8 @@ describe('Chart.plugins', function() {
await jasmine.triggerMouseEvent(chart, 'mousemove', {x: 0, y: 0});
await jasmine.triggerMouseEvent(chart, 'test', {x: 0, y: 0});
await jasmine.triggerMouseEvent(chart, 'test2', {x: 0, y: 0});
expect(results).toEqual(['beforetest', 'aftertest']);
await jasmine.triggerMouseEvent(chart, 'pointerleave', {x: 0, y: 0});
expect(results).toEqual(['beforetest', 'aftertest', 'beforemouseout', 'aftermouseout']);
});
});
});

0 comments on commit 50ad163

Please sign in to comment.