Visitar URL original
Fix Escape handling in language selector by arpitjain099 · Pull Request #6713 · uswds/uswds · GitHub
Skip to content

Fix Escape handling in language selector - #6713

Merged
ethangardner merged 4 commits into
uswds:developfrom
arpitjain099:chore/fix-language-selector-escape
Jul 28, 2026
Merged

ethangardner merged 4 commits into
uswds:developfrom
arpitjain099:chore/fix-language-selector-escape

Conversation

@arpitjain099

Copy link
Copy Markdown
Contributor

Fixes #6496

Language selector no longer calls a removed method on Escape. This replaces the stale toggleLanguage call in the focus trap Escape handler with the same dropdown-close path used elsewhere in the component.

I also added a regression test that dispatches Escape from a submenu link and asserts there is no throw and the menu closes.

How to test:

  • Open a language selector with a submenu.
  • Open the menu and focus a submenu link.
  • Press Escape and confirm no console error occurs and the menu closes.

Verification run locally:

  • npx eslint packages/usa-language-selector/src/index.js packages/usa-language-selector/src/test/language-selector.spec.js
  • node jsdom harness for submenu Escape path (no throw + aria-expanded false)

Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
@chandracarney chandracarney added Package: Language selector Work affecting Language selector. Apply only when this area helps route or find the issue. Needs: Internal Response 🔴 Waiting for a named maintainer or team decision. Record the question; remove when answered. labels Jun 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

✅ All commits on this PR have a verified signature. Thanks!

@ethangardner ethangardner left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for contributing this fix. The runtime code change itself looks good. Replacing that stale callback with the existing dropdown close path makes sense.

I do have a comment on here regarding an update to the test you added. If you can make that change, I think this will be ready to merge.

Comment thread packages/usa-language-selector/src/test/language-selector.spec.js Outdated
@github-project-automation github-project-automation Bot moved this from Triage to In progress in USWDS Core Project Data Jul 28, 2026
@ethangardner ethangardner removed the Needs: Internal Response 🔴 Waiting for a named maintainer or team decision. Record the question; remove when answered. label Jul 28, 2026
@ethangardner ethangardner moved this from In progress to Peer Review in USWDS Core Project Data Jul 28, 2026
arpitjain099 and others added 2 commits July 29, 2026 01:29
The earlier test dispatched Escape from a submenu link, which the
component's own keydown binding already handled, so it passed on the base
branch too. Activate the FocusTrap before dispatching and surface listener
errors through window.onerror, since jsdom swallows them. This now fails on
the base branch with the stale toggleLanguage call and passes with the fix.

Signed-off-by: Arpit Jain <arpitjain099@gmail.com>

@ethangardner ethangardner left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Thanks for the contribution.

@ethangardner
ethangardner merged commit 6c8bde9 into uswds:develop Jul 28, 2026
6 checks passed
@github-project-automation github-project-automation Bot moved this from Peer Review to Fed Final Review in USWDS Core Project Data Jul 28, 2026
@ethangardner ethangardner added this to the uswds 3.14.0 - Aug 2026 milestone Aug 4, 2026
@annepetersen annepetersen added the ❤️ Thanks Historical appreciation marker. Prefer a reaction; not required for triage. label Aug 5, 2026
@chandracarney chandracarney moved this from Fed Final Review to Done in USWDS Core Project Data Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Package: Language selector Work affecting Language selector. Apply only when this area helps route or find the issue. ❤️ Thanks Historical appreciation marker. Prefer a reaction; not required for triage.

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

USWDS - Bug: Language Selector calls nonexistent method

4 participants