Skip to content

fix: show tooltips when target is partially visible - #5932

Merged
sissbruecker merged 1 commit into
mainfrom
fix/avatar_tooltip
Jun 2, 2023
Merged

sissbruecker merged 1 commit into
mainfrom
fix/avatar_tooltip

Conversation

@sissbruecker

Copy link
Copy Markdown
Member

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

sonarqubecloud Bot commented Jun 2, 2023

Copy link
Copy Markdown

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

expect(overlay.opened).to.be.false;
});

describe('target is fully visible', () => {

Copy link
Copy Markdown
Member 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.

@web-padawan web-padawan left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
Member 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.

@sissbruecker
sissbruecker merged commit 06f17d9 into main Jun 2, 2023
@sissbruecker
sissbruecker deleted the fix/avatar_tooltip branch June 2, 2023 07:58
sissbruecker added a commit that referenced this pull request Jun 2, 2023
Co-authored-by: Sascha Ißbrücker <sissbruecker@vaadin.com>
sissbruecker added a commit that referenced this pull request Jun 2, 2023
Co-authored-by: Sascha Ißbrücker <sissbruecker@vaadin.com>
sissbruecker added a commit that referenced this pull request Jun 2, 2023
Co-authored-by: Sascha Ißbrücker <sissbruecker@vaadin.com>
@vaadin-bot

Copy link
Copy Markdown
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