HoverCard: Target props event listener not updating.
On HoverCard, it seems that whenever target props is updated, the mouseEvenetListener for on the target element did not get updated.
Environment Information
- Release (6.142.1)
Please provide a reproduction of the bug in a codepen:
https://codepen.io/lauwrentius/pen/GzeyrZ
Actual behavior:
- Hover to Element1
- Click button
Set Hover to Target El2 - Hover event triggers when user hover on Element1, while the HoverCard is positioned at Element2
Expected behavior:
- Hover to Element1
- Click button
Set Hover to Target El2 - Hover event triggers when user hover on Element2
Are you willing to submit a PR to fix? Yes
Hi @lauwrentius, sorry for the delayed response. When the HoverCard was built the intention was to have a HoverCard for each target on the page and not reassign the target by some events on the page. We are really curious about the use cases of this scenario. Also, you mentioned that you are willing to submit a PR for this issue so please feel free to do so and we will happily review it.
P.S.: In the codepen you provided you set the state inside your render method which is not recommended. You can see the console warning from React screaming about it))))
The change was quick enough to submit a fix in #8287. @lauwrentius can you still elaborate on your use case scenario why reuse the same HoverCard for multiple targets and not create a HoverCard to be ready for each target? What are your events on the page that trigger a target change?
Hi, Thank you for the fix. We're incorporating Hovercard on a graph element using Highchart. However, whenever the data is updated, the element (svg object) is disposed and replaced by a new element, which makes the HoverCard loses its eventListener.
:tada:This issue was addressed in #8287, which has now been successfully released as [email protected].:tada:
Handy links: