Skip to content

Ploty.js in Shadow DOM hover flicker #5277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dbluhm opened this issue Nov 14, 2020 · 14 comments · Fixed by #6021
Closed

Ploty.js in Shadow DOM hover flicker #5277

dbluhm opened this issue Nov 14, 2020 · 14 comments · Fixed by #6021
Labels
bug something broken
Milestone

Comments

@dbluhm
Copy link
Contributor

dbluhm commented Nov 14, 2020

When Plotly.js is rendered inside of a ShadowDOM, the hover elements rapidly draw, clear, and redraw causing a flickering effect on mousemove events under specific conditions.

Demonstration in codepen

And a GIF
hover-flicker

For comparision, here is the same example as above using the Light DOM:
Demonstration in codepen

And a GIF
expected-hover

When it comes to support for Plotly.js in Shadow DOM, there are other issues in addition to this one but, as demonstrated in the first code pen, there are workable fixes I can make as a user in most cases (i.e. the styling inside of the template...) but this particular issue is not so easily worked around as a user.

@alexandergerber
Copy link

I am having the same issue. After some digging the problem could be tracked down to all plots which are using a rect with
class="nsewdrag drag" for the tooltips. This includes all plots using a cartesian coordinate system.

Other plots like Sankey diagrams are not affected.

The difference we found was that for the plot where the problems exist the tooltips are not triggered by hovering over the visible objects directly (underlined in blue) but by the extra layer mentioned above (underlined in red).
image

In other types of plots where the tooltip does not rely on that additional layer there is no problem.

As far as I understand the mouseposition within the rect is compared to that of the graphical elements in the plot. If there is a match the tooltip is shown.

I would like to help fixing that issue. Is there any idea what could be causing it?

@dbluhm
Copy link
Contributor Author

dbluhm commented Jan 4, 2021

@alexandergerber to clarify, this is occurring within a ShadowDOM element and the behavior is not exhibited in normal "LightDOM" elements?

@alexandergerber
Copy link

alexandergerber commented Jan 4, 2021

@dbluhm Yes. I am trying to use plotly within a Web Component. Outside ShadowDOM elements it works correctly.

@dbluhm
Copy link
Contributor Author

dbluhm commented Jan 4, 2021

@alexandergerber does the codepen I shared also encapsulate your findings? If not, would you be able to provide one that does? I think that would help ensure we're looking at the same issue. It might also be interesting to try out changes from the (incomplete) PR I have open addressing this issue and seeing if that fixes the behavior you're seeing on the other graphs

@alexandergerber
Copy link

alexandergerber commented Jan 4, 2021

I would say it is exactly the same issue. I checked out your pull request and can try if it fixes the problem for me.
When I have tested your changes I'll report my findings.

@archmoj archmoj added this to the v1.59.0 milestone Jan 5, 2021
@alexandergerber
Copy link

alexandergerber commented Jan 6, 2021

We tested this and it seems not to work for our plots. It seems that the problem only occurs in the lower part of the plot and also only at specific pixels.

@magdyamr542
Copy link

unfortunately we also have the same problem. the unhover event gets fired even if the mouse is on the box or the bar.
that causes the tooltip to disappear of course and even if we used a custom tooltip we still depend on the unhover event fired from plotly to know when to hide the tooltip.

I have added here some screenshots from the code and hopefully someone can help fix this issue soon.

the Tooltip disappears back and forth because of the unhover event.

E38A5199-F8BC-4749-B483-D4AD168B

the function where we listen to the unhover event from plotly

image

the function where we fetch the html div element from the shadow root

image

@archmoj
Copy link
Contributor

archmoj commented Jan 6, 2021

We tested this and it seems not to work for our plots. It seems that the problem only occurs in the lower part of the plot and also only at specific pixels.

It seems working on this codepen.
How did you test it?
Please provide a minimal codepen illustrating the problem.

@magdyamr542
Copy link

magdyamr542 commented Jan 6, 2021

it does not work as expected in the codepin that you sent me either. the tooltip disappears frequently even if iam still on the bar.

this codepen prints in console the unhover events. you can see that the unhover event gets fired over and over again with the mouse being on the bars.

i hope this could help.

@alexandergerber
Copy link

alexandergerber commented Jan 6, 2021

Ich also checked out the codepen example. I found the problem there as well.
plotly_issue

It also seems worse in the bottom part of the graph.

@archmoj
Copy link
Contributor

archmoj commented Jan 28, 2021

Fixed by #5256.

@archmoj archmoj closed this as completed Jan 28, 2021
@alexandergerber
Copy link

I don't think this should have been closed. I just tested it with 2.0 and the problem still persists.

@LeUser111
Copy link

Just upgraded to version 2.2.0 - problem is still there!

@skordesign
Copy link

Is there any update on this? I use version 2.33.0 and the issue still happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants