plotly / plotly/react-plotly.js
Event Handlers Don't Update
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.1k
- Forks
- 138
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 4
Description
I'm using 2.3.0 and noticed that the code doesn't account for an event handler prop changing. So, for instance, if I have a component with:
const MyComponent = ({ someCallback }) => (
<Plot
data={data}
onRelayout={someCallback}
/>
);
The someCallback that is called is the first one. Here's a Codepen reproducing:
https://codepen.io/gonzofish/pen/OevOjx
To see it in action, just click autoscale on the chart and you'll see the message change to "Callback 1 Reporting In". If you change the callback by clicking "Change to 2" and then clicking autoscale again, the message doesn't change, despite the callback being changed.
I believe the issues stems from syncEventHandlers only account for two modes: (1) the handler isn't already set but has been provided as a prop and (2) the handler was set but the prop is not longer there. That starts at:
https://github.com/plotly/react-plotly.js/blob/master/src/factory.js#L212
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/factory.js around line 212, where syncEventHandlers handles plot event props, and use the linked CodePen reproduction to observe the callback change. Done means changing the onRelayout prop causes the next autoscale event to invoke the new callback rather than the original one.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- data-visualization, frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100