Repository navigation
fix(core): type-to-select takes a letter typed with AltGr - #12644
Conversation
Fixes #12620. Reported by Rajatendu1.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
/approve-spec c305465 |
PR Analysis Report🔎 Preview ·
|
| 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.
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
There was a problem hiding this comment.
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:668has no test (reverting that line keeps every Selector test green), so add ahasSearchcase that firesłwithctrlKey,altKeyandmodifierAltGraphon the closed trigger and expects the search input to holdł, asarchitecture:component-test-sufficiencyINV3 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
mainand passes here). - AltGr reports Control too, and type-to-select dropped the letter as a Control shortcut: verified (
main's check inuseTypeahead.tsskipped every key with Control). - The fix covers
useTypeaheadand 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:80and: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 onmainand 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 missinghasSearchcase belongs here).packages/core/src/hooks/useTypeahead.test.tsx: clear.packages/core/src/TreeList/TreeList.test.tsx: clear.
|
/approve-spec bf17c3c |
There was a problem hiding this comment.
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
useTypeaheadand 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:80and: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 newhasSearchtest 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 onmain'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
hasSearchcase; 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
useTypeaheadpass 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.
| // 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. |
There was a problem hiding this comment.
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.











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,
isShortcutChordinutils/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.Selector/hooks.ts).useTreeFocus), which also skipped every key with Alt; AltGr reports Alt too, so a key with AltGraph active is let through there.Records
architecture:internationalizationINV17: type-to-select compares the typed letters to labels the same way in every locale, inuseTypeaheadand 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
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 anduseTypeaheadat this head: 17 files, 410 tests pass.tscclean; strict ESLint clean on the changed files; Prettier andcheck:changesetspass.