Remove tooltip focus on mousemove#3335
Conversation
|
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
|
💚 CLA has been signed |
|
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
|
👋 Welcome, @adfaris! Can you please sign the CLA? Be sure to sign it with the same email address as your github account. Be sure to also checkout our Contributing guide. |
Hi @cchaos, Thank you for the warm welcome. I just verified my email settings on GitHub and resigned the form. No updates yet. |
Nevermind, it worked. Thanks |
|
Jenkins, test this |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_3335/ |
|
Test passed locally and should pass in CI now. |
src/components/tool_tip/tool_tip.tsx
Outdated
| hasFocus: true, | ||
| }); | ||
| this.showToolTip(); | ||
| window.addEventListener('mousemove', this.hasFocusMouseMoveListener); |
There was a problem hiding this comment.
Hmm, my main concern is adding this handler to hide the tooltip on any mouse movement. Example:
It means that if the element that has a tooltip is interact-able (can have a focus state) and is focused, the tooltip disappears almost immediately when clicked on because of any slight movement with the mouse. It can just be a bit funky to interact with.
I offer this worry, but without a solid solution. Like a global tooltip service that manages the number of tooltips visible, which sounds like a headache from a system point of view. Or if #2560 is truly an issue that arises often or an issue at all.
There was a problem hiding this comment.
The behavior for mousing over is not changed. It only listens for and closes the tooltip on any mousemove when the tooltip is opened via tabbing onto it on the keyboard.
When I view this in the build for this PR: https://eui.elastic.co/pr_3335/#/display/badge, the tooltip only closes on mouseout, like before, not on any mousemove.
I figured that this was the only practical solution, because switching from using a keyboard to a mouse seems appropriate to close a tooltip. I also think that a global registry may be more headache than it's worth.
There was a problem hiding this comment.
This event listener is added in the onFocus method which is only called when it is entered via keyboard tab.
There was a problem hiding this comment.
Yep, totally understand. However, you can enter the focus state with a mouse as well. For instance, if the anchoring element is just a toggle or a switch and doesn't actually navigate the user anywhere. Once the user clicks on the anchor (switch), any subsequent movement will close the tooltip.
There was a problem hiding this comment.
Ah, I see. Thanks.
Maybe we can be more specific on the event handler by applying the event listener only if it was a focus event with the tab key index as well. Thoughts?
|
@cchaos. Please re-review when you get a chance. I have made the necessary changes and everything is working. |
|
Jenkins, test this |
|
Build is failing because it can't install yarn. |
|
retest |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_3335/ |
|
Hi again @adfaris. Sorry for the extremely late response on this one. I've been going back and forth in my head whether the combination of keyboard tabbing and mousing around would be normal practice or if it would be odd to see the tooltip disappear when doing so. Eventually I've landed on, no, I don't think this is a common case nor would it look unintended. So in that regard, I think this is a good final solution 💯 I think all it needs now is a Changelog entry since this does effect the shipped components. |
|
The CHANGELOG has been updated. |
|
Thanks @adfaris, looks like you'll need to rebase with master since there's been several releases and the changelog is out of date. |
|
Hmm, that rebase didn't go so well, I'll get it cleaned up for you. |
6be9742 to
ea1a6fa
Compare
|
retest |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_3335/ |
|
jenkins test this |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_3335/ |
7fdac01 to
dca4496
Compare
Please re-review it when you get a chance. The bug has been fixed. |
chandlerprall
left a comment
There was a problem hiding this comment.
Changes LGTM, will merge on green CI. Thanks @adfaris !
|
jenkins test this |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_3335/ |
|
jenkins test this |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_3335/ |
This reverts commit fd3dd84. # Conflicts: # CHANGELOG.md # src/components/tool_tip/tool_tip.tsx


Summary
Resolves #2560
When a tooltip is opened via tab focus, any mouse movement will now close it. There will not be two tooltips opened at the same time.
Checklist
- [ ] Checked in IE11 and Firefox
- [ ] Props have proper autodocs
- [ ] Added documentation examples
- [ ] Added or updated jest tests
- [ ] Checked for breaking changes and labeled appropriately
- [ ] Checked for accessibility including keyboard-only and screenreader modes