Purging and removing element while hovering causes "undefined is not an object"
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 18.3k
- Forks
- 2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 28
Description
So, I'm unsure if this issue is with the react library or this one. But the responsible code resides in this repository so I'll try my luck here.
If you unmount a plot rendered in react while hovering your mouse over it, maindrag.onmouseout gets triggered before all event handlers are completely unregistered.
This causes the error undefined is not an object (evaluating 'gd._fullLayout._hoversubplot = null') at plotly.js:148662==graph_interact.js:79. I looked into it with a breakpoint and the issue seems to be that _fullLayout doesn't exist anymore on gd.
A simple fix (assuming this is an issue with plotly.js and not react-plotly.js) could be to just add || !dg._fullLayout to graph_interact.js:74. If it isn't an issue with plotly itself, it may still be a good idea to wrap the event handlers with try/catch and log a warning about not unmounting correctly instead of a flat out error.
Contributor guide
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/plots/cartesian/graph_interact.js around lines 74-79 and reproduce the failure by unmounting a React-rendered plot while hovering. Verify that the hover cleanup no longer throws when gd._fullLayout is absent, while preserving the normal mouseout behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100