USWDS - Tooltip: Add opacity:0 to initial state#5475
Merged
Conversation
mahoneycm
approved these changes
Sep 1, 2023
mahoneycm
left a comment
Contributor
There was a problem hiding this comment.
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!
mejiaj
reviewed
Sep 12, 2023
mejiaj
left a comment
Contributor
There was a problem hiding this comment.
LGTM, just a minor note on documenting why we need the style rule.
Co-authored-by: James Mejia <james.mejia@gsa.gov>
mejiaj
approved these changes
Sep 12, 2023
thisisdano
approved these changes
Sep 28, 2023
thisisdano
left a comment
Contributor
There was a problem hiding this comment.
Simple and effective!
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.