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

Cannot read properties of null (reading 'addEventListener') #11677

Closed
DAcodedBEAT opened this issue Feb 21, 2024 · 4 comments · Fixed by #11685
Closed

Cannot read properties of null (reading 'addEventListener') #11677

DAcodedBEAT opened this issue Feb 21, 2024 · 4 comments · Fixed by #11685

Comments

@DAcodedBEAT
Copy link
Contributor

DAcodedBEAT commented Feb 21, 2024

Expected behavior

addEventListener and removeEventListener should only be callable on valid defined and non-null elements.

Current behavior

TypeError: Cannot read properties of null (reading 'addEventListener')
  at addListener(../../node_modules/chart.js/dist/chart.js:3234:8)
  at createProxyAndListen(../../node_modules/chart.js/dist/chart.js:3360:15)
  at DomPlatform.addEventListener(../../node_modules/chart.js/dist/chart.js:3406:21)
  at _add(../../node_modules/chart.js/dist/chart.js:6216:16)
  at <anonymous>(../../node_modules/chart.js/dist/chart.js:6224:41)
  at each(../../node_modules/chart.js/dist/chunks/helpers.segment.js:56:12)
  at _a.bindUserEvents(../../node_modules/chart.js/dist/chart.js:6224:10)
  at _a.bindEvents(../../node_modules/chart.js/dist/chart.js:6205:10)
  at _a._checkEventBindings(../../node_modules/chart.js/dist/chart.js:5903:12)
  at _a.update(../../node_modules/chart.js/dist/chart.js:5852:10)
  at this._doResize(../../node_modules/chart.js/dist/chart.js:5620:46)
  at sentryWrapped(../../node_modules/@sentry/browser/esm/helpers.js:37:17)

From sentry:

image

Reproducible sample

.

Optional extra steps/info to reproduce

No response

Possible solution

Here is what I am proposing: DAcodedBEAT@8930d19

Context

chart.js version

4.4.1

Browser name and version

Chrome >=120 and Edge >= 120 according to my project's Sentry, but probably many others

Link to your project

No response

@DAcodedBEAT
Copy link
Contributor Author

@chartjs sorry for the ping but I want to resolve this. I have asked about it about a month ago, I have provided a solution, and would like your input so I can contribute my fix.

@DAcodedBEAT
Copy link
Contributor Author

@etimberg / @LeeLenaleee seeing that you are recent contributors, I'm pinging you both about this issue (as per the recommendation from the support discord).

@etimberg
Copy link
Member

@DAcodedBEAT the proposed changes make sense to me if you'd like to send a PR

@DAcodedBEAT
Copy link
Contributor Author

Thanks @etimberg! I opened #11685 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants