Skip to content

fix: Dismiss chart tooltip on ESC key press#167

Merged
Who-is-PS merged 2 commits intomainfrom
dev-v3-philosr-chart-fix
Feb 13, 2026
Merged

fix: Dismiss chart tooltip on ESC key press#167
Who-is-PS merged 2 commits intomainfrom
dev-v3-philosr-chart-fix

Conversation

@Who-is-PS
Copy link
Member

@Who-is-PS Who-is-PS commented Feb 13, 2026

Description

Users can now press ESC to dismiss hover tooltips. Keyboard navigation remains unaffected - ESC moves focus up the hierarchy when navigating with keyboard.

Related links, issue #, if available: AWSUI-61678

How has this been tested?

Did run through my pipeline and checked it on the website

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.

@Who-is-PS Who-is-PS requested a review from a team as a code owner February 13, 2026 07:14
@Who-is-PS Who-is-PS requested review from amanabiy and removed request for a team and amanabiy February 13, 2026 07:14
@Who-is-PS Who-is-PS marked this pull request as draft February 13, 2026 07:50
@Who-is-PS Who-is-PS requested a review from mxschll February 13, 2026 09:32
@Who-is-PS Who-is-PS changed the title fix: Esc works in new charts fix: Dismiss chart tooltip on ESC key press Feb 13, 2026
@Who-is-PS Who-is-PS marked this pull request as ready for review February 13, 2026 09:37
const handleKeyDown = (event: KeyboardEvent) => {
// Skip if keyboard navigation is handling this (event originated from application element)
const target = event.target as Element;
if (context.keyboardNavigationEnabled && target?.closest('[role="application"]')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do wen need to check for target?.closest('[role="application"]')?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prevents double-handling. The navigation handler in chart-extra-navigation.ts already handles Escape for keyboard nav, this check skips the global handler when navigation is active.

].includes(event.keyCode)
) {
event.preventDefault();
event.stopPropagation();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this break other event handlers? E.g. if I am currently in the keyboard navigation, and I have an event listener on the parent element, does it still get triggered?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, intentionally. Standard role="application" behavior, captures all keys to prevent parent handlers (page scrolling, modal closing, etc.) from interfering with chart navigation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if this role is not set? Or can't that happen?

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 should not happen in practice because, the role="application" is hardcoded in the ChartApplication component (it's not configurable). The application element is only rendered when keyboardNavigation={true}.

But if hypothetically it wasn't set: the global Escape handler would run during keyboard navigation, causing tooltip to dismiss when user meant to exit navigation.

@Who-is-PS Who-is-PS added this pull request to the merge queue Feb 13, 2026
Merged via the queue into main with commit 7b7899e Feb 13, 2026
46 of 47 checks passed
@Who-is-PS Who-is-PS deleted the dev-v3-philosr-chart-fix branch February 13, 2026 11:11
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.

2 participants