Skip to content

Conversation

@bmichalowski
Copy link

@bmichalowski bmichalowski commented Nov 21, 2025

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.

tooltip_follow-mouse-mode_missing-tooltip-on-focus
tooltip_follow-mouse-mode_prev-posirion-bug

QA steps

Bug 1: Tooltip is not visible on keyboard focus in followMouse mode

  1. Given the tooltip is in followMouse mode
  2. And the user has focused the element with the tooltip using the TAB key
  3. When the element receives focus
  4. Then the tooltip should be visible

Bug 2: Tooltip appears at previous cursor location instead of current

  1. Given the tooltip is in followMouse mode
  2. And the user hovers over an element on the left side
  3. And then moves the cursor away from the element
  4. When the user hovers over an element on the right side
  5. Then the tooltip should appear next to the current cursor position
  6. And not at the previous location

Percy steps

No visual changes expected

@webteam-app
Copy link

bmichalowski is not a collaborator of the repo

@bmichalowski
Copy link
Author

@canonical/react-library-maintainers please take a look at the proposed changes

Copy link
Contributor

@edlerd edlerd left a 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.

Comment on lines +311 to +318
if (followMouse) {
if (wrapperRef.current) {
// set initial position for the tooltip
setPositionStyle(
getPositionStyle(adjustedPosition, wrapperRef.current)
);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
followMouse,
useListener(wrapperRef.current, mouseHandler, "mousemove", true, followMouse);

This whole block should be in a single line now.

@edlerd
Copy link
Contributor

edlerd commented Dec 10, 2025

Please stash all your commits with the formatting changes into one for a clean history.

@edlerd
Copy link
Contributor

edlerd commented Dec 10, 2025

Also, please rebase on the main branch to pull in recent updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants