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

fix: Allow hover tooltips to be dismissed using Esc #3217

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

avinashbot
Copy link
Member

@avinashbot avinashbot commented Jan 24, 2025

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

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link

codecov bot commented Jan 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.42%. Comparing base (708ecb7) to head (68333e9).
Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

}: TooltipProps) {
if (!trackKey && (typeof value === 'string' || typeof value === 'number')) {
trackKey = value;
}

useEffect(() => {
Copy link
Member Author

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]);
Copy link
Member Author

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.

@avinashbot avinashbot marked this pull request as ready for review January 29, 2025 14:49
@avinashbot avinashbot requested a review from a team as a code owner January 29, 2025 14:49
@avinashbot avinashbot requested review from georgylobko and removed request for a team January 29, 2025 14:49
@johannes-weber johannes-weber self-requested a review January 30, 2025 15:13
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.

1 participant