Skip to content

fix(core): guard empty Typeahead navigation#4060

Open
Kevinjohn wants to merge 1 commit into
facebook:mainfrom
Kevinjohn:fix/typeahead-empty-active-descendant
Open

fix(core): guard empty Typeahead navigation#4060
Kevinjohn wants to merge 1 commit into
facebook:mainfrom
Kevinjohn:fix/typeahead-empty-active-descendant

Conversation

@Kevinjohn

Copy link
Copy Markdown

Typeahead no longer exposes a dangling aria-activedescendant when its open results list is empty.

Fixes #4059

  • Sequence: enter a query with no matches, then press ArrowDown or Home.
  • Expected: 0 results and no active descendant.
  • Before: the input referenced <listbox-id>-option-0 while 0 option nodes existed.
  • After: the highlighted index remains -1 and aria-activedescendant stays absent.

Root cause

ArrowDown wrapped an empty result set to index 0, and Home assigned index 0 unconditionally while the popover was open.

Changes

  • Keep ArrowDown at -1 when there are no results.
  • Keep Home at -1 when there are no results.
  • Cover both keys with a parameterized regression test.
  • Add a patch changeset for @astryxdesign/core.

Actual screenshots

Before — Storybook (facebook/astryx@2e2e96046):

Typeahead empty-results reproduction before the fix

Before — focused regression:

Focused Typeahead regression failures before the fix

After — Storybook (Kevinjohn/astryx@dcc4491fc):

Typeahead empty-results reproduction after the fix

After — focused regression:

Focused Typeahead regression tests passing after the fix

Validation

  • vitest run packages/core/src/Typeahead/Typeahead.test.tsx — 44/44 passed
  • vitest run --project ui — 225 files, 4,853 tests passed
  • pnpm -F @astryxdesign/core build
  • pnpm lint — 0 errors
  • git diff --check

@vercel

vercel Bot commented Jul 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview, Comment Jul 18, 2026 6:54pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 18, 2026
@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Jul 18, 2026
@Kevinjohn
Kevinjohn marked this pull request as ready for review July 18, 2026 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Typeahead exposes a nonexistent active descendant for empty results

1 participant