-
Notifications
You must be signed in to change notification settings - Fork 162
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: Allow hover tooltips to be dismissed using Esc #3217
base: main
Are you sure you want to change the base?
Conversation
b0eb3ac
to
aa34e19
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3217 +/- ##
==========================================
- Coverage 96.45% 96.42% -0.04%
==========================================
Files 791 791
Lines 22315 22343 +28
Branches 7667 7662 -5
==========================================
+ Hits 21524 21544 +20
- Misses 739 746 +7
- Partials 52 53 +1 ☔ View full report in Codecov by Sentry. |
aa34e19
to
b237085
Compare
}: TooltipProps) { | ||
if (!trackKey && (typeof value === 'string' || typeof value === 'number')) { | ||
trackKey = value; | ||
} | ||
|
||
useEffect(() => { |
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.
This is the new addition! The rest is just basically scaffolding.
@@ -61,6 +61,9 @@ const Item = ( | |||
|
|||
const { descriptionEl, descriptionId } = useHiddenDescription(disabledReason); | |||
|
|||
const [canShowTooltip, setCanShowTooltip] = useState(true); | |||
useEffect(() => setCanShowTooltip(true), [highlighted]); |
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.
Doing this to reset the canShowTooltip
state when highlight moves to another item.
Description
Does what it says on the tin - tooltips should be dismissible by hitting the Escape key. I know the visibility logic for the tooltips is handled outside them, but it still seemed sensible to put the dismiss handler inside the tooltip in one shared place.
Not as complicated as it looks! A lot of it is just unit testing or just implementing the new
onDismiss
handler, which is super simple. Check my comments to see the areas of interest first.Related links, issue #, if available: AWSUI-60227, AWSUI-60225, AWSUI-60230, AWSUI-60226, AWSUI-60228, AWSUI-60231, AWSUI-60229
How has this been tested?
Added a unit test to the tooltip component itself, and all other components that use it.
Review checklist
The following items are to be evaluated by the author(s) and the reviewer(s).
Correctness
CONTRIBUTING.md
.CONTRIBUTING.md
.Security
checkSafeUrl
function.Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.