Skip to content

fix: Focus lock uses correct direction when initial focus is outside the lock#4518

Merged
pan-kot merged 1 commit into
mainfrom
chart-tooltip-focus-fix
May 15, 2026
Merged

fix: Focus lock uses correct direction when initial focus is outside the lock#4518
pan-kot merged 1 commit into
mainfrom
chart-tooltip-focus-fix

Conversation

@pan-kot
Copy link
Copy Markdown
Member

@pan-kot pan-kot commented May 15, 2026

Description

The focus lock is commonly used with auto-focus (via autoFocus prop or manual). Thus, the focus is always inside the lock, and the tab traps behaviour is correct: upon reaching the last tab trap - the focus must move to the 1st focusable element, and vice-versa.

However, this use case (cloudscape-design/chart-components#217) requires the tooltip wrapped with focus lock to not automatically move focus inside when it appears. Should the user move focus by pressing Tab - it would hit the 1st tab trap, which distributes focus to the last element of the lock content.

See before:

Focusing with Tab navigates to "3" button first. Focusing with Shift+Tab navigates to "1" button first.

Screen.Recording.2026-05-15.at.11.21.31.mov

After:

Screen.Recording.2026-05-15.at.11.22.41.mov

How has this been tested?

  • New unit tests
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.

@pan-kot pan-kot marked this pull request as ready for review May 15, 2026 09:32
@pan-kot pan-kot requested a review from a team as a code owner May 15, 2026 09:32
@pan-kot pan-kot requested review from cansuaa and removed request for a team May 15, 2026 09:32
@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.42%. Comparing base (81c2e51) to head (6c2cfb5).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4518   +/-   ##
=======================================
  Coverage   97.42%   97.42%           
=======================================
  Files         936      936           
  Lines       29616    29619    +3     
  Branches    10761    10762    +1     
=======================================
+ Hits        28852    28857    +5     
- Misses        716      755   +39     
+ Partials       48        7   -41     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pan-kot pan-kot enabled auto-merge May 15, 2026 11:40
@pan-kot pan-kot added this pull request to the merge queue May 15, 2026
Merged via the queue into main with commit ea35614 May 15, 2026
84 of 86 checks passed
@pan-kot pan-kot deleted the chart-tooltip-focus-fix branch May 15, 2026 13:43
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