-
Notifications
You must be signed in to change notification settings - Fork 68
fix(tooltip): fix wrong initial and focus tooltip positions in followMouse mode #1278
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
base: main
Are you sure you want to change the base?
fix(tooltip): fix wrong initial and focus tooltip positions in followMouse mode #1278
Conversation
|
bmichalowski is not a collaborator of the repo |
|
@canonical/react-library-maintainers please take a look at the proposed changes |
edlerd
left a comment
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.
Thank you for the contribution. This is an improved handling of the follow mouse mode indeed!
Some small nitpicks on formatting below, then this LGTM to merge.
| if (followMouse) { | ||
| if (wrapperRef.current) { | ||
| // set initial position for the tooltip | ||
| setPositionStyle( | ||
| getPositionStyle(adjustedPosition, wrapperRef.current) | ||
| ); | ||
| } | ||
| } |
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.
| if (followMouse) { | |
| if (wrapperRef.current) { | |
| // set initial position for the tooltip | |
| setPositionStyle( | |
| getPositionStyle(adjustedPosition, wrapperRef.current) | |
| ); | |
| } | |
| } | |
| if (followMouse && wrapperRef.current) { | |
| // set initial position for the tooltip | |
| setPositionStyle(getPositionStyle(adjustedPosition, wrapperRef.current)); | |
| } | |
| openPortal(); |
A bit simpler and please use correct spacing and formatting.
| "mousemove", | ||
| true, | ||
| followMouse && isOpen, | ||
| followMouse, |
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.
| followMouse, | |
| useListener(wrapperRef.current, mouseHandler, "mousemove", true, followMouse); |
This whole block should be in a single line now.
|
Please stash all your commits with the formatting changes into one for a clean history. |
|
Also, please rebase on the main branch to pull in recent updates. |
Done
The tooltip did not handle the initial position correctly in followMouse mode.
There was also an issue with listening to mouse move events only when the tooltip was open.
QA
Pinging @canonical/react-library-maintainers for a review.
QA steps
Bug 1: Tooltip is not visible on keyboard focus in followMouse mode
Bug 2: Tooltip appears at previous cursor location instead of current
Percy steps
No visual changes expected