Skip to content
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

Tooltip/popover placement update #9457

Merged
merged 8 commits into from Apr 10, 2023
Merged

Tooltip/popover placement update #9457

merged 8 commits into from Apr 10, 2023

Conversation

agr
Copy link
Contributor

@agr agr commented Apr 6, 2023

Addresses #9424 and maybe some others.

Old behavior

Tooltip always appears to the right of the "parent" element and is inserted after it into the DOM tree sharing the same parent. This results in two things:

  1. tooltips often try to occupy as little horizontal space as possible:
    image
  2. When there is not enough space to the right to fit it, it is drawn off screen (and horizontal scrollbar appears for the window):
    image

New behavior

Tooltips are now parented to the body element, which results in them using as much horizontal space as possible (up to the limits set in bootstrap CSS for those):
image

When there is little (<150 CSS pixels) space on the right side, the tooltip is shown above the "parent" element and if the page is scrolled down so that there isn't much space on top (<100 CSS pixels, fits 3 lines of text usually), it is drawn to the bottom of the "parent" element.

image

image

I had to resort to magic numbers in determining the direction as by the time placement function is called the exact size of the tooltip is undetermined.

The change is applied to all tooltips, so it addresses similar issues in other locations: blue checkmark tooltips on package details page and in search results, framework tooltips on package details page, etc.

getBoundingClientRect support matrix:

image

@agr agr requested a review from a team as a code owner April 6, 2023 23:42
joelverhagen
joelverhagen previously approved these changes Apr 7, 2023
Copy link
Member

@joelverhagen joelverhagen left a comment

Choose a reason for hiding this comment

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

Nice thinking checking the support matrix.

🚢

@agr agr merged commit 1028137 into dev Apr 10, 2023
1 check passed
@agr agr deleted the agr-popovers branch April 10, 2023 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants