Skip to content

fix(core): type-to-select takes a letter typed with AltGr - #12644

Merged
cixzhang merged 2 commits into
mainfrom
lane2/typeahead-altgraph
Nov 18, 2026
Merged

cixzhang merged 2 commits into
mainfrom
lane2/typeahead-altgraph

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #12620. Reported by Rajatendu1.

User impact

On Windows, with a keyboard layout that types letters through AltGr, such as Polish, typing ł in a Selector, a menu or a TreeList did nothing, so a person could not type to reach "Łódź". AltGr reports Control as well as Alt, and type-to-select read every key with Control as a shortcut and dropped it. Now a letter typed with AltGr selects a matching item, as any other typed letter does. Control and Command shortcuts, such as Control+L, still do not type-select. No API change.

Change

One check, isShortcutChord in utils/typeaheadMatch.ts, decides whether a key is a Control or Command shortcut: Command always is, and Control is only when the AltGraph modifier is not active. Each type-to-select path uses it in place of its own !e.ctrlKey && !e.metaKey:

  • useTypeahead (Selector, MultiSelector, DropdownMenu and its sub-menus, ContextMenu, NavHeadingMenu, TopNavMenu, BreadcrumbItem), for a typed letter and for Space in the middle of a query.
  • A searchable Selector's typed-to-open query (Selector/hooks.ts).
  • TreeList's typeahead (useTreeFocus), which also skipped every key with Alt; AltGr reports Alt too, so a key with AltGraph active is let through there.

Records

architecture:internationalization INV17: type-to-select compares the typed letters to labels the same way in every locale, in useTypeahead and every collection with type-to-select, and a typed stroked letter such as ł reaches "Łódź" and puts it first. On Windows, AltGr+L is how ł is typed, so dropping it broke INV17. No record change.

Overlap checked: #12227, #12122, #11749, #4690, #12605, #12591, #12307, #12087, #12075, #11987 (they touch these source or test files for other behavior; none changes a Control, Command, Alt or AltGraph check)

Test plan

  • Red first, on main's source with this head's tests: useTypeahead "reaches a stroked letter typed with AltGr, which reports Control and Alt (INV17)", Selector "selects an option from a letter typed with AltGr (INV17)", Selector "seeds a letter typed with AltGr on a closed hasSearch trigger (INV17)" and TreeList "typeahead reaches a stroked label from a letter typed with AltGr (INV17)" fail; "still ignores Control+L without AltGr" passes on both. All four pass here.
  • useTypeahead, useTreeFocus, typeaheadMatch, Selector, MultiSelector, TreeList, DropdownMenu and ContextMenu: 45 files, 1,331 tests pass. With the searchable Selector's seed line alone reverted to !e.ctrlKey && !e.metaKey, its new case fails; Selector and useTypeahead at this head: 17 files, 410 tests pass.
  • Core tsc clean; strict ESLint clean on the changed files; Prettier and check:changesets pass.

@vercel

vercel Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 18, 2026 4:58pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 18, 2026
@astracat-bot

astracat-bot Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 18, 2026, 9:52 PM UTC

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec c305465

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · bf17c3c

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
Selector 114.9 kB (+44 B) · 18.7 kB CSS (0) — ✗ · ✓ · ✓
SelectorOption 24.2 kB (0) · 6.7 kB CSS (0) — ✗ · ✓ · ✓
MultiSelector 103.3 kB (+56 B) · 17.8 kB CSS (0) — — · — · —
18 more components
Component Size LoC Visual · A11y · RTL
CommandPalette 78.7 kB (+43 B) · 12.8 kB CSS (0) — — · — · —
TreeList · Storybook 46.5 kB (+42 B) · 5.9 kB CSS (0) 1,229 (0) ✓ · ✓ · ✓
DropdownMenu 108.8 kB (+34 B) · 18.9 kB CSS (0) — — · — · —
NavHeadingMenu 18.7 kB (+34 B) · 3.5 kB CSS (0) — — · — · —
PowerSearch 310.5 kB (+33 B) · 25.6 kB CSS (0) — — · — · —
richtext/RichTextEditorToolbar 309.3 kB (+31 B) · 454 B CSS (0) — — · — · —
MoreMenu 109.1 kB (+30 B) · 18.9 kB CSS (0) — — · — · —
Markdown 205.5 kB (+27 B) · 22.1 kB CSS (0) — — · — · —
Table 121.8 kB (+27 B) · 19.8 kB CSS (0) — — · — · —
TopNavMenu 82.9 kB (+24 B) · 12.0 kB CSS (0) — — · — · —
TableHeaderCell 104.5 kB (+22 B) · 19.1 kB CSS (0) — — · — · —
DropdownMenuSubMenu 78.9 kB (+21 B) · 10.5 kB CSS (0) — — · — · —
ContextMenu 103.4 kB (+20 B) · 18.8 kB CSS (0) — — · — · —
BreadcrumbItem 98.0 kB (+19 B) · 13.3 kB CSS (0) — — · — · —
lab/Comments 379.1 kB (+17 B) · 2.5 kB CSS (0) — — · — · —
TableCell 104.7 kB (+13 B) · 19.3 kB CSS (0) — — · — · —
lab/CommentThread 372.3 kB (+2 B) · 2.4 kB CSS (0) — — · — · —
Pagination 147.7 kB (−5 B) · 19.1 kB CSS (0) — — · — · —
Visual changes: 4 snapshots in 1 component

A change is a question for the reviewer, not a failure.

Component · story Before After Diff
Selector · Indicator Space Bottom Sheet Wide Start (neutral, dark) · inheritance unknown: not found in the 3 newest reports of other pull requests before frame after frame diff frame
Selector · Indicator Space Bottom Sheet Wide Start (neutral, light) · inheritance unknown: not found in the 3 newest reports of other pull requests before frame after frame diff frame
Selector · Indicator Space Bottom Sheet Narrow End RTL (neutral, dark) · inheritance unknown: not found in the 3 newest reports of other pull requests before frame after frame diff frame
Selector · Indicator Space Bottom Sheet Narrow End RTL (neutral, light) · inheritance unknown: not found in the 3 newest reports of other pull requests before frame after frame diff frame

Inheritance checked against the 3 newest reports of other pull requests.

Package size: @astryxdesign/core 7.68 MB packed (+612 B); no new dependencies.

Touched components checked; for the full suites, add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot Bot 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.

Requesting changes: the AltGr fix is correct and keeps Control and Command shortcuts ignored, but one of the three paths it fixes has no regression test.

  • The searchable Selector fix at packages/core/src/Selector/hooks.ts:668 has no test (reverting that line keeps every Selector test green), so add a hasSearch case that fires ł with ctrlKey, altKey and modifierAltGraph on the closed trigger and expects the search input to hold ł, as architecture:component-test-sufficiency INV3 requires for a defect fix.

The three new tests fail on main and pass here. Optional: the comment above isSpaceMidType in useTypeahead.ts still says "ctrl or meta", though an AltGr Space now extends the query. CI has not run on this head yet because the pull request is a draft.

Claims and files checked

Review mode: same-head; reason: none

Changed rules since the earlier review (0): none

Claims (changeset and description):

  • A letter typed with AltGr, such as ł, now selects a matching item, so ł in a Selector reaches "Łódź": verified (the new Selector test fails on main and passes here).
  • AltGr reports Control too, and type-to-select dropped the letter as a Control shortcut: verified (main's check in useTypeahead.ts skipped every key with Control).
  • The fix covers useTypeahead and the collections that use it (Selector, MultiSelector, DropdownMenu and its sub-menus, ContextMenu, NavHeadingMenu, TopNavMenu, BreadcrumbItem), for a typed letter and for Space in the middle of a query: verified (each calls the shared hook before any modifier check of its own; useTypeahead.ts:80 and :167).
  • A searchable Selector's typed-to-open query takes the letter: verified in code (Selector/hooks.ts:668), with no test (the blocking finding above).
  • TreeList takes the letter, including past its own Alt exclusion when AltGraph is active: verified (useTreeFocus.ts:510-512; the new TreeList test fails on main and passes here).
  • Control and Command shortcuts such as Control+L still do not type-select: verified (typeaheadMatch.ts:156-161; "still ignores Control+L without AltGr").
  • One shared check decides what counts as a shortcut, Command always and Control only without AltGraph: verified (typeaheadMatch.ts:156, called from all three paths).
  • No API change: verified (the new helper is not exported from any package entry, and the built API surface is unchanged).
  • The change restores the internationalization rule that type-to-select works the same in every locale, with no record change: verified (no record is edited; the rule covers every collection with type-to-select).
  • The ten overlapping pull requests listed touch these files but change no Control, Command, Alt or AltGraph check: verified (their file lists and patches).
  • Red first: the three AltGr tests fail on main's source and the Control+L test passes on both; all four pass here: verified.
  • The named suites pass (45 files, 1,331 tests), and typecheck, strict lint, formatting and changeset checks are clean: verified.
  • Fixes #12620, reported by Rajatendu1: verified (the issue describes the same bug).

Files:

  • .changeset/typeahead-altgr-letters.md: clear (a Core patch whose text matches the code).
  • packages/core/src/utils/typeaheadMatch.ts: clear.
  • packages/core/src/hooks/useTypeahead.ts: clear (optional comment fix at lines 162-164).
  • packages/core/src/hooks/useTreeFocus.ts: clear.
  • packages/core/src/Selector/hooks.ts: blocking finding (line 668 has no regression test).
  • packages/core/src/Selector/Selector.test.tsx: clear (the missing hasSearch case belongs here).
  • packages/core/src/hooks/useTypeahead.test.tsx: clear.
  • packages/core/src/TreeList/TreeList.test.tsx: clear.

Automated review (maintainer link)

Comment thread packages/core/src/Selector/hooks.ts Resolved
Comment thread packages/core/src/hooks/useTypeahead.ts Resolved
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec bf17c3c

@astracat-bot astracat-bot Bot 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.

Approved: CI passed every suite on this head, including one interaction test shard that passed on its second attempt after the first was cancelled.

Each of the three type-to-select paths this changes has a test that fails without the fix, and Control and Command shortcuts stay ignored.

  • Optional: the Space comment in packages/core/src/hooks/useTypeahead.ts (lines 161-165) puts two points in one 29-word sentence; a shorter form is suggested inline.
Claims and files checked

Review mode: same-head; reason: none

changed rules (0): none

Claims (changeset and description):

  • A letter typed with AltGr, such as ł, now selects a matching item, so ł in a Selector reaches "Łódź": verified (the new Selector test fails on main's source and passes here; a Chromium check on both trees agrees).
  • AltGr reports Control too, and type-to-select dropped the letter as a Control shortcut: verified (the base filters skipped every key with Control).
  • The fix covers useTypeahead and the collections that use it (Selector, MultiSelector, DropdownMenu and its sub-menus, ContextMenu, NavHeadingMenu, TopNavMenu, BreadcrumbItem), for a typed letter and for Space in the middle of a query: verified (useTypeahead.ts:80 and :168; each collection calls the shared hook with no modifier check of its own first).
  • A searchable Selector's typed-to-open query takes the letter: verified (Selector/hooks.ts:668; the new hasSearch test fails with that line alone reverted).
  • TreeList takes the letter, past its own Alt exclusion while AltGraph is active: verified (useTreeFocus.ts:510-512; the new TreeList test fails on main's source).
  • Control and Command shortcuts such as Control+L still do not type-select: verified (typeaheadMatch.ts:156-161; "still ignores Control+L without AltGr" passes on both).
  • One shared check decides what counts as a shortcut, Command always and Control only without AltGraph: verified (typeaheadMatch.ts:156, called from all three paths).
  • No API change: verified (the built API surface of Core, the build package and the seven themes is unchanged, and CI's API delta for this head lists no row).
  • The internationalization rule that type-to-select compares typed letters the same way in every locale covers this, with no record change: verified (no record is edited).
  • The ten overlapping pull requests listed touch these files for other behavior and change no Control, Command, Alt or AltGraph check in them: verified (their patches).
  • Red first: the four AltGr tests fail on main's source with this head's tests, and the Control+L test passes on both: verified.
  • The named suites pass (45 files): verified (1,332 tests at this head, one more than the description's count, which predates the new hasSearch case; CI's unit run also passes the four touched suites).
  • With only the searchable Selector's seed line reverted its new case fails, and Selector plus useTypeahead pass at this head (17 files, 410 tests): verified.
  • Typecheck, strict lint, formatting and changeset checks pass: verified (CI's typecheck and Lint jobs on this head, plus strict ESLint, Prettier and the changeset check on the changed files).
  • Fixes #12620, reported by Rajatendu1: verified (the issue describes the same bug and the same rule).

Files:

  • .changeset/typeahead-altgr-letters.md: clear (a Core patch whose text matches the code).
  • packages/core/src/utils/typeaheadMatch.ts: clear.
  • packages/core/src/hooks/useTypeahead.ts: clear (optional comment rewording at lines 161-165).
  • packages/core/src/hooks/useTreeFocus.ts: clear.
  • packages/core/src/Selector/hooks.ts: clear.
  • packages/core/src/Selector/Selector.test.tsx: clear.
  • packages/core/src/hooks/useTypeahead.test.tsx: clear.
  • packages/core/src/TreeList/TreeList.test.tsx: clear.

Automated review (maintainer link)

Comment on lines 161 to +165
// A bare Space with no active buffer is not typeahead (menus activate on
// Space); once the user is mid-typing, Space extends the query. Chorded
// with ctrl or meta it is neither — that is an OS or IME shortcut, and
// consuming it would append a raw space that poisons the whole buffer.
// Space); once the user is mid-typing, Space extends the query. With a
// Control or Command shortcut it is neither — that is an OS or IME
// shortcut, and consuming it would append a raw space that poisons the
// whole buffer.

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.

Optional (comment style): the last sentence here runs 29 words and carries two points. A shorter form that keeps only the reason:

      // A bare Space with no active buffer is not typeahead: menus activate on
      // Space. Mid-query, Space extends the query. With a Control or Command
      // shortcut, Space belongs to the OS or IME. Adding it to the query would
      // stop every later match.

This branch was successfully deployed

1 active deployment
Preview — bf17c3c6 Deployed Nov 18, 2026 by vercel[bot]
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Selector type-to-select ignores printable AltGr letters

1 participant