-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Fire unhover when dragging plot #5407
Conversation
Oh, and to be clear, |
Thanks for the PR! |
We do have an event |
@alexcjohnson Yes, I can pass it in. Then I think I just need to invert the logic and prevent this from firing on every drag move event: plotly.js/src/components/dragelement/unhover.js Lines 36 to 40 in 997946b
|
Okay, sorry, had to dust this off and double-check it. I think it now passes the event through but uses |
Debugging nontrivial/non-fluke test failure. |
Update: I rebuilt on circle-ci and am maybe >85% confident that this is not actually a real test failure related to the changes in this PR. |
@archmoj I don't currently have additional things to add to this PR. It looks like it did eventually pass all tests on circle-ci. Just let me know if there's anything else you'd like to have happen on this PR, otherwise I'll put the ball in your court to hit the button and merge, unless you prefer otherwise. |
Overall LGTM. Let's me have a second look. |
@@ -34,7 +34,7 @@ unhover.raw = function raw(gd, evt) { | |||
var oldhoverdata = gd._hoverdata; | |||
|
|||
if(!evt) evt = {}; | |||
if(evt.target && | |||
if(evt.target && !gd._dragged && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I'll check that as well.
@archmoj Pardon the slow turnaround, but I've added a test and confirmed that this change fixes it! I thought about _editing and, in particular based on your example, I don't immediately see that the behavior should change if editing, no? |
Nicely done. |
Fixes #5437.
This PR makes a small change to unhover behavior. My premise is that, toward hooking up external HTML/CSS hovers,
plotly_hover
andplotly_unhover
should be enough to manage hover state.The GIF below shows plotly hover along with HTML/CSS hover.
plotly_unhover
does not currently fire when you drag the plot, resulting in a stray hover.The cause is this conditional, which is not passed the event from the onMove handler, hence
evt.target
is empty.plotly.js/src/components/dragelement/unhover.js
Line 47 in af9d440
plotly.js/src/components/dragelement/index.js
Lines 181 to 184 in af9d440
One solution, without adding additional flags, is to check if the plot is being dragged and fire the event if so. Then, hover/unhover are sufficient to manage the state in this case.
(It could pass the event from onMove in order to accomplish this, but then
plotly_beforehover
is fired many times while dragging, which would require other flags and fixes to avoid)/cc @plotly/plotly_js @jonmmease and probably also @nicolaskruchten @alexcjohnson