-
Notifications
You must be signed in to change notification settings - Fork 81
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: Fix Tooltip positioning #1878
Conversation
…react-uswds into 1877-tooltip-positioning-fix
While trying this branch out on my project, I realized that there were more issues with positioning - the code to loop through the various positions wasn’t working as expected. I think it was because the code to set the new CSS and check if the element was visible or not were all happening in the same The new way this works is: when the tooltip gets shown, it sets the position to whatever was intended. in a second It is possible that it won’t find a position that works… this might happen if the tooltip contents is very long and/or the window is SO small that there’s no room. I checked and this can come up in the USWDS implementation as well. I put a I also added more Storybook stories to demonstrate the auto-positioning/wrapping (try changing the viewport size). Finally… while working on this I also discovered what I think is a USWDS bug so I filed uswds/uswds#4458 |
// This should be set by USWDS but isn't | ||
// It can be removed when https://github.com/uswds/uswds/issues/4458 is fixed | ||
.usa-tooltip__body { | ||
opacity: 0; | ||
} |
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.
Nice!
Summary
Updates the code used to position the Tooltip component to reflect USWDS 2.11.2 Tooltip source code. This seems to resolve the positioning bug.
Related Issues or PRs
Fixes #1877
How To Test
View the Tooltip component in Storybook at various screen sizes and verify the tooltip is always visible and positioned as expected.
Screenshots (optional)