Plotly_selected is not triggered on selection changes because of legend events

Hello!

I am trying to perform lasso selection and want to show the number of points selected in the UI.

I can get the details of the points from plotly_selected event. But when I click on any legends that have associated points in the lasso region, then obviously the selection changes, but plotly_selected event is not triggered.

I have replicated this behavior in the codepen.

Should I need to handle this behavior differently to get the selection details? Please share your thoughts on this.