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

fix: show tooltips when target is partially visible #5932

Merged
merged 1 commit into from
Jun 2, 2023

Conversation

sissbruecker
Copy link
Contributor

Description

Currently a tooltip is only shown when its target is fully visible. That is an issue with avatar for example, which uses a negative margin that can pull it out of its scroll container if put right at the edge of it. It can also be confusing that a tooltip doesn't show for an element where only a single pixel is scrolled outside of the view.

This change makes tooltips show if their target is partially visible (even just a single pixel). I considered using some magic number between 0 and 1 for the threshold, but again it could be confusing why tooltips show / hide based on different scroll positions, even though the element is effectively visible for the user.

Fixes vaadin/flow-components#5105

Type of change

  • Bugfix

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jun 2, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

});

describe('target is fully visible', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed this suite / test, as the test case should already be covered by the two previous tests.

Copy link
Member

@web-padawan web-padawan left a comment

Choose a reason for hiding this comment

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

The only problem I can think of is positioning tooltip for the partially visible element:

Screenshot 2023-06-02 at 10 46 38

Could be reproduced with the following HTML in the dev page:

<style>
  #container {
    width: 200px;
    height: 200px;
    border: solid 1px #e2e2e2;
    overflow: scroll;
  }
</style>


<div id="container">
  Lorem ipsum dolor sit amet consectetur adipisicing elit. Sunt sapiente fuga unde dolore, harum voluptatibus, similique culpa illo quae eveniet esse. Adipisci omnis beatae delectus iure labore nihil velit quas.
  Lorem ipsum dolor sit amet consectetur adipisicing elit. Sunt sapiente fuga unde dolore, harum voluptatibus, similique culpa illo quae eveniet esse. Adipisci omnis beatae delectus iure labore nihil velit quas.
  Lorem ipsum dolor sit amet consectetur adipisicing elit. Sunt sapiente fuga unde dolore, harum voluptatibus, similique culpa illo quae eveniet esse. Adipisci omnis beatae delectus iure labore nihil velit quas.
  Lorem ipsum dolor sit amet consectetur adipisicing elit. Sunt sapiente fuga unde dolore, harum voluptatibus, similique culpa illo quae eveniet esse. Adipisci omnis beatae delectus iure labore nihil velit quas.
  <button id="test">Test</button>
  <vaadin-tooltip text="Testing" for="test"></vaadin-tooltip>
  Lorem ipsum dolor sit amet consectetur adipisicing elit. Sunt sapiente fuga unde dolore, harum voluptatibus, similique culpa illo quae eveniet esse. Adipisci omnis beatae delectus iure labore nihil velit quas.
  Lorem ipsum dolor sit amet consectetur adipisicing elit. Sunt sapiente fuga unde dolore, harum voluptatibus, similique culpa illo quae eveniet esse. Adipisci omnis beatae delectus iure labore nihil velit quas.
  Lorem ipsum dolor sit amet consectetur adipisicing elit. Sunt sapiente fuga unde dolore, harum voluptatibus, similique culpa illo quae eveniet esse. Adipisci omnis beatae delectus iure labore nihil velit quas.
  Lorem ipsum dolor sit amet consectetur adipisicing elit. Sunt sapiente fuga unde dolore, harum voluptatibus, similique culpa illo quae eveniet esse. Adipisci omnis beatae delectus iure labore nihil velit quas.
</div>

@sissbruecker
Copy link
Contributor Author

As discussed, let's go with the current approach for now. If the positioning turns out to be a problematic use-case then we can consider tweaking the visibility threshold or make the overlay positioning consider the intersection rectangle.

@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with Vaadin 24.2.0.alpha1 and is also targeting the upcoming stable 24.2.0 version.

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.

Avatar tooltip not displayed on hover
3 participants