Skip to content

fix(hooks): cycle useTreeFocus typeahead on repeated letters - #4844

Open
alex-js-ltd wants to merge 3 commits into
facebook:mainfrom
alex-js-ltd:fix/tree-focus-typeahead-cycling
Open

fix(hooks): cycle useTreeFocus typeahead on repeated letters#4844
alex-js-ltd wants to merge 3 commits into
facebook:mainfrom
alex-js-ltd:fix/tree-focus-typeahead-cycling

Conversation

@alex-js-ltd

@alex-js-ltd alex-js-ltd commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Resolves #4843.

Problem

useTreeFocus has its own typeahead implementation, which has drifted from the shared useTypeahead behavior.

This causes three related issues:

  • repeated letters build queries like "aa" instead of cycling through matches;
  • with no focused treeitem, the first match is searched last;
  • multi-character queries skip the current item even when it still matches.

For example, pressing p twice quickly in the FullyExpanded TreeList story stalls on public instead of advancing to package.json.

Fix

Align useTreeFocus with the typeahead semantics being established in #3797:

  • repeated characters collapse back to a single-character query;
  • search ordering now distinguishes between cycling a single character and refining a multi-character query.

No public API changes.

Tests

Added regression coverage for all three cases:

  • repeated-letter cycling;
  • searching from the first item when nothing is focused;
  • keeping focus when the current item still matches a refined query.

Before the fix: 3 failing, 13 passing
After the fix: 16 passing

Also verified the full ui test suite (6472/6472 passing), Prettier, ESLint, core typecheck, and check:changesets.

Reproduce manually

Open the [FullyExpanded story](https://facebook.github.io/astryx/storybook/index.html?path=/story/core-treelist--fully-expanded), click a row, then press p twice quickly.

Before: focus stops on public.
After: focus advances to package.json.

@vercel

vercel Bot commented Aug 9, 2026

Copy link
Copy Markdown

@alex-js-ltd is attempting to deploy a commit to the Meta Open Source Team on Vercel.

A member of the Team first needs to authorize it.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 9, 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 Aug 9, 2026
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.7KB 1.2KB

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

github-actions Bot added a commit that referenced this pull request Aug 9, 2026
@alex-js-ltd
alex-js-ltd force-pushed the fix/tree-focus-typeahead-cycling branch from d21c9bd to f92e230 Compare August 10, 2026 08:55
github-actions Bot added a commit that referenced this pull request Aug 10, 2026
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] TreeList typeahead stalls when the same letter is pressed twice

1 participant