Skip to content

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

@donavan-tangible

Description

@donavan-tangible

Expected behavior

Check if canvas is 'null' before calling addListener(canvas, type,proxy).

function createProxyAndListen(chart, type, listener) {
const canvas = chart.canvas;
const proxy = helpers_segment.throttled((event)=>{
if (chart.ctx !== null) {
listener(fromNativeEvent(event, chart));
}
}, chart);
addListener(canvas, type, proxy);
return proxy;
}

Current behavior

Cannot read properties of null (reading 'addEventListener')
TypeError: Cannot read properties of null (reading 'addEventListener')
at addListener (http://localhost:3000/static/js/bundle.js:323367:8)
at createProxyAndListen (http://localhost:3000/static/js/bundle.js:323496:3)
at DomPlatform.addEventListener (http://localhost:3000/static/js/bundle.js:323539:21)
at _add (http://localhost:3000/static/js/bundle.js:326413:16)
at http://localhost:3000/static/js/bundle.js:326421:96
at each (http://localhost:3000/static/js/bundle.js:332240:12)
at Chart.bindUserEvents (http://localhost:3000/static/js/bundle.js:326421:66)
at Chart.bindEvents (http://localhost:3000/static/js/bundle.js:326402:10)
at Chart._checkEventBindings (http://localhost:3000/static/js/bundle.js:326088:12)
at Chart.update (http://localhost:3000/static/js/bundle.js:326032:10)

Reproducible sample

www.noexample.com

Optional extra steps/info to reproduce

No response

Possible solution

No response

Context

No response

chart.js version

4.2.1

Browser name and version

No response

Link to your project

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions