Plotly_click fired twice when clicked once

Hello guys, I’m binding and creating a method that listens to plotly_click event.

this.handleDataClick = this.handleDataClick.bind(this);
chartContainer.on(‘plotly_click’, this.handleDataClick);

The thing is that when I click the chart, this event gets fired twice. Could there be a workaround for this issue? am I the only one facing this problem?
Already tried it with latest version.

Sounds like a bug.

Would you mind sharing a reproducible example to help us debug?

Will try to see if I can make an example in CodePen.

1 Like

I found that the problem that is causing this issue to reproduce is that if you add two plotly_click with same function, it generates two listeners for the chart. So maybe somewhere in my code, I’m attaching the listener twice. Guess it’s more of a logic bug on my side rather than a plotly bug.

Do you know how can I remove ‘plotly_click’ (listener) before adding a new one for plotly?

Do you know how can I remove ‘plotly_click’ (listener) before adding a new one for plotly?

// with
function listener () {}
gd.on('plotly_click', listener)

// either
gd.removeListener('plotly_click', listener)

// or
gd.removeAllListeners('plotly_click')