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

USWDS - Tooltip: Add opacity:0 to initial state #5475

Merged
merged 2 commits into from
Sep 28, 2023

Conversation

amyleadem
Copy link
Contributor

@amyleadem amyleadem commented Aug 29, 2023

Summary

Restored the opacity: 0 style rule to the tooltip body's initial state. This prevents the component from flickering if its position needs to be recalculated.

Breaking change

This is not a breaking change.

Related issue

Closes #4458

Related pull requests

Changelog PR

Preview link

Tooltip component

Problem statement

To prevent flickering in the tooltip component, the tooltip is programmed to receive an opacity shift slightly after the tooltip positioning is set. This comment explains that the initial state should be set to opacity: 0 so that any position changes will occur when the component is visibly hidden.

However, the tooltip does not receive an initial style of 0 opacity, which can result in flickering.

It looks like this CSS declaration used to exist, but was possibly removed by mistake when refactoring how the tooltip positioning works (see the code changes in this PR).

Solution

Reinstating the initial opacity: 0 style rule should allow the is-visible class to perform as expected and prevent flickering in the tooltip.

Testing and review

  • Open the tooltip component and confirm that the tooltip toggles visibility as expected.
  • Confirm that toggling the is-visible class in web inspector shows and hides the component as expected.

Copy link
Contributor

@mahoneycm mahoneycm left a comment

Choose a reason for hiding this comment

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

Code is working great!

I had to add the class is-set in addition to is-visible while testing the class additions, but hover toggling worked as expected!

Copy link
Contributor

@mejiaj mejiaj left a comment

Choose a reason for hiding this comment

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

LGTM, just a minor note on documenting why we need the style rule.

packages/usa-tooltip/src/styles/_usa-tooltip.scss Outdated Show resolved Hide resolved
Co-authored-by: James Mejia <james.mejia@gsa.gov>
Copy link
Member

@thisisdano thisisdano left a comment

Choose a reason for hiding this comment

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

Simple and effective!

@thisisdano thisisdano merged commit e69625e into develop Sep 28, 2023
3 checks passed
@thisisdano thisisdano mentioned this pull request Sep 29, 2023
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.

USWDS - Bug: Tooltip opacity is not set to 0
4 participants