-
Notifications
You must be signed in to change notification settings - Fork 934
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
Conversation
There was a problem hiding this 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!
There was a problem hiding this 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.
Co-authored-by: James Mejia <james.mejia@gsa.gov>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simple and effective!
Summary
Restored the
opacity: 0style 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: 0so 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: 0style rule should allow theis-visibleclass to perform as expected and prevent flickering in the tooltip.Testing and review
is-visibleclass in web inspector shows and hides the component as expected.