fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

HoverCard: Target props event listener not updating.

Open lauwrentius opened this issue 7 years ago • 4 comments

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:

  1. Hover to Element1
  2. Click button Set Hover to Target El2
  3. Hover event triggers when user hover on Element1, while the HoverCard is positioned at Element2

Expected behavior:

  1. Hover to Element1
  2. Click button Set Hover to Target El2
  3. Hover event triggers when user hover on Element2

Are you willing to submit a PR to fix? Yes

lauwrentius avatar Feb 21 '19 19:02 lauwrentius

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))))

Vitalius1 avatar Mar 12 '19 21:03 Vitalius1

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?

Vitalius1 avatar Mar 12 '19 22:03 Vitalius1

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.

lauwrentius avatar Mar 12 '19 22:03 lauwrentius

:tada:This issue was addressed in #8287, which has now been successfully released as [email protected].:tada:

Handy links:

msft-github-bot avatar Mar 15 '19 12:03 msft-github-bot