Skip to content

Conversation

@ggdouglas
Copy link
Contributor

@ggdouglas ggdouglas commented Nov 26, 2025

Fixes #7594

Summary

Adds Escape key support to dismiss Tooltips, bringing Blueprint into compliance with WCAG 2.1 Success Criterion 1.4.13 and the WAI-ARIA Tooltip Pattern.

Before After
before after

Problem

Tooltips in Blueprint could not be dismissed using the Escape key, which violates:

  1. WCAG 2.1 SC 1.4.13 (Content on Hover or Focus) - requires a mechanism to dismiss content without moving pointer hover or keyboard focus
  2. WAI-ARIA Tooltip Pattern - explicitly specifies that pressing Escape should dismiss tooltips

Previous Behavior

  • Tooltip had canEscapeKeyClose={false} hardcoded
  • Even if enabled, Escape wouldn't work because Overlay2's handler only fires when the container has focus
  • Tooltips use autoFocus={false} to avoid stealing focus on hover

Solution

Added a document-level Escape key listener to Overlay2 that activates when autoFocus={false}. Tooltip no longer hardcodes canEscapeKeyClose={false}, allowing it to inherit the default true value from Overlay2 while keeping autoFocus={false} to prevent focus steal on hover.

Testing

  1. Hover over a tooltip target
  2. Tooltip appears
  3. Press Escape key
  4. Tooltip dismisses without moving pointer
  5. Focus remains on the original element

@changelog-app
Copy link

changelog-app bot commented Nov 26, 2025

Generate changelog in packages/core/changelog/@unreleased

Type (Select exactly one)

  • Feature (Adding new functionality)
  • Improvement (Improving existing functionality)
  • Fix (Fixing an issue with existing functionality)
  • Break (Creating a new major version by breaking public APIs)
  • Deprecation (Removing functionality in a non-breaking way)
  • Migration (Automatically moving data/functionality to a new system)

Description

[core][a11y] Enable Escape key dismissal for Tooltips

Check the box to generate changelog(s)

  • Generate changelog entry

@svc-palantir-github
Copy link

Add functionality to allow Tooltips to be esc-key closed

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

Copy link
Contributor

@mm-wang mm-wang left a comment

Choose a reason for hiding this comment

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

Any chance we can get a test for multiple overlays?

});
});

describe("keyboard interactions", () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

question: Open to using React Testing Library for new tests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[a11y] Tooltips cannot be dismissed with Escape key

4 participants