Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Legend plugin is missing events property in typings #11283

Closed
elinake opened this issue May 12, 2023 · 1 comment · Fixed by #11350
Closed

Legend plugin is missing events property in typings #11283

elinake opened this issue May 12, 2023 · 1 comment · Fixed by #11350
Labels
type: bug type: types Typescript type changes

Comments

@elinake
Copy link

elinake commented May 12, 2023

Expected behavior

I have a custom plugin that listens to mouseup events, and I want to be able to use the signal disabling feature of legend. Usually plugins take use of events property, but with typescript that is not possible, because it gives error that events property doesn't exist (see example).

Without typescript it is possible, but not using typescript is unfortunately not an option for me.

Current behavior

What happens now in the example, is that legend's onClick is run twice, therefore disabling and enabling the signal immediately. In the code it looks like mouseup and onClick are treated as the same event:

582:

function isListened(type, opts) {
  if (opts.onClick && (type === 'click' || type === 'mouseup')) {
    return true;
  }
  return false;
}

528:

  handleEvent(e) {
    if (!isListened(e.type, opts)) {
      return;
    }
    if (e.type === 'mousemove' || e.type === 'mouseout') {
    [...]
    } else if (hoveredItem) {
      call(opts.onClick, [e, hoveredItem, this], this);
    }
  }

Reproducible sample

https://stackblitz.com/edit/angular-chart-js-xkhcjv?file=src%2Fapp%2Fapp.component.ts,src%2Fapp%2Fapp.component.html

Optional extra steps/info to reproduce

No response

Possible solution

No response

Context

No response

chart.js version

v4.3.0

Browser name and version

No response

Link to your project

No response

@elinake
Copy link
Author

elinake commented Jul 25, 2023

The fix doesn't work, because Legend does not extend Plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug type: types Typescript type changes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants