Repository navigation
feat(BaseTypeahead, Typeahead): a menu config with listbox and dialog roles, and an open handle - #10544
Conversation
… an open handle BaseTypeahead takes `menu`, which chooses what its anchored menu shows while Astryx keeps the layer (position, top layer, outside press, Escape, focus return, ARIA). The listbox role may put information around the result list; anything a person acts on stays a result, and a control outside the list warns in development. The dialog role shows content that takes focus in a dialog named by `label`; closing it returns focus to the element focused when it opened, or to the input, and it does not close on an empty query or an input blur. `handleRef` exposes open() and close(); onOpenChange reports changes; there is no controlled open state. open() runs after the commit it is called in, and a pick whose onChange calls open() keeps the menu open, so a role switch keeps the same layer with no close in between. Typeahead and Tokenizer forward the menu (Tokenizer in its inline presentation, with onOpenChange and open/close on its handle). Records: BaseTypeahead FR13-FR16, AR6, ORD3 and DEC-1 (row 49 A), Typeahead FR11, Tokenizer FR28. Adds the BaseTypeaheadMenu CLI block (the docsite example), a Menu story and a Chromium spec.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| Typeahead | 80.8 kB (+1.1 kB) · 12.4 kB CSS (0) | — | ✓ · ✓ · ✓ |
| PowerSearch | 289.3 kB (+966 B) · 24.2 kB CSS (0) | — | — · — · — |
| Tokenizer | 92.4 kB (+908 B) · 18.8 kB CSS (0) | — | — · — · — |
48 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| BaseTypeahead | 72.1 kB (+900 B) · 10.9 kB CSS (0) | — | ✓ · ✓ · ✓ |
| Selector | 100.4 kB (+200 B) · 17.4 kB CSS (0) | — | — · — · — |
| MultiSelector | 95.2 kB (+198 B) · 16.8 kB CSS (0) | — | — · — · — |
| TopNavMenu | 74.9 kB (+188 B) · 11.2 kB CSS (0) | — | — · — · — |
| TabMenu | 72.1 kB (+181 B) · 11.1 kB CSS (0) | — | — · — · — |
| DateInput | 187.2 kB (+175 B) · 17.0 kB CSS (0) | — | — · — · — |
| DateTimeInput | 208.9 kB (+175 B) · 18.7 kB CSS (0) | — | — · — · — |
| SideNavItem | 70.8 kB (+175 B) · 11.1 kB CSS (0) | — | — · — · — |
| lab/CommentComposer | 152.4 kB (+174 B) · 1.9 kB CSS (0) | — | — · — · — |
| TopNavHeading | 75.5 kB (+173 B) · 11.2 kB CSS (0) | — | — · — · — |
| Pagination | 110.4 kB (+170 B) · 17.8 kB CSS (0) | — | — · — · — |
| ChatComposerInput | 76.4 kB (+169 B) · 11.3 kB CSS (0) | — | — · — · — |
| SideNavHeading | 75.9 kB (+169 B) · 11.3 kB CSS (0) | — | — · — · — |
| BreadcrumbItem | 85.0 kB (+168 B) · 12.1 kB CSS (0) | — | — · — · — |
| ChatComposerTokenElement | 76.4 kB (+167 B) · 11.3 kB CSS (0) | — | — · — · — |
| richtext/RichTextEditorToolbar | 278.7 kB (+166 B) · 454 B CSS (0) | — | — · — · — |
| lab/ChatEmojiPicker | 106.3 kB (+163 B) · 773 B CSS (0) | — | — · — · — |
| ChatComposer | 78.7 kB (+162 B) · 12.0 kB CSS (0) | — | — · — · — |
| DateRangeInput | 93.0 kB (+161 B) · 12.5 kB CSS (0) | — | — · — · — |
| TopNavMegaMenu | 70.0 kB (+157 B) · 11.8 kB CSS (0) | — | — · — · — |
| MoreMenu | 97.7 kB (+156 B) · 17.6 kB CSS (0) | — | — · — · — |
| lab/TourStep | 97.6 kB (+153 B) · 590 B CSS (0) | — | — · — · — |
| lab/Comments | 352.2 kB (+149 B) · 2.5 kB CSS (0) | — | — · — · — |
| lab/CommentThread | 345.3 kB (+146 B) · 2.4 kB CSS (0) | — | — · — · — |
| Popover · Storybook | 91.2 kB (+145 B) · 14.2 kB CSS (0) | 1,549 (+9) | ✓ · ✓ · ✓ |
| lab/TransferListSelector | 109.9 kB (+144 B) · 1.4 kB CSS (0) | — | — · — · — |
| lab/ChatReactionBar | 107.4 kB (+142 B) · 1.1 kB CSS (0) | — | — · — · — |
| ComplexSelector | 71.3 kB (+139 B) · 11.8 kB CSS (0) | — | — · — · — |
| DropdownMenu | 97.4 kB (+135 B) · 17.6 kB CSS (0) | — | — · — · — |
| Drawer | 50.8 kB (+116 B) · 8.3 kB CSS (0) | — | — · — · — |
| ContextMenu | 109.0 kB (+1 B) · 17.4 kB CSS (0) | — | — · — · — |
| AlertDialog | 105.6 kB (0) · 14.6 kB CSS (0) | — | — · — · — |
| AppShell | 91.6 kB (0) · 13.5 kB CSS (0) | — | — · — · — |
| BottomSheet | 68.3 kB (0) · 7.7 kB CSS (0) | — | — · — · — |
| Dialog | 24.0 kB (0) · 6.9 kB CSS (0) | — | — · — · — |
| DropdownMenuSubMenu | 70.4 kB (0) · 9.7 kB CSS (0) | — | — · — · — |
| Lightbox | 122.6 kB (0) · 10.6 kB CSS (0) | — | — · — · — |
| MobileNav | 70.7 kB (0) · 10.6 kB CSS (0) | — | — · — · — |
| SideNav | 114.7 kB (0) · 11.4 kB CSS (0) | — | — · — · — |
| Table | 125.6 kB (0) · 18.3 kB CSS (0) | — | — · — · — |
| TableCell | 110.2 kB (0) · 17.9 kB CSS (0) | — | — · — · — |
| TimeInput | 162.5 kB (0) · 16.0 kB CSS (0) | — | — · — · — |
| TopNav | 72.4 kB (0) · 10.9 kB CSS (0) | — | — · — · — |
| TypeaheadItem | 6.4 kB (0) · 3.6 kB CSS (0) | — | ✓ · ✓ · ✓ |
| BottomSheetSwitcher | 17.9 kB (−1 B) · 3.4 kB CSS (0) | — | — · — · — |
| CommandPalette | 73.4 kB (−1 B) · 12.7 kB CSS (0) | — | — · — · — |
| Markdown | 188.4 kB (−1 B) · 20.6 kB CSS (0) | — | — · — · — |
| TableHeaderCell | 109.8 kB (−1 B) · 17.7 kB CSS (0) | — | — · — · — |
Package size: @astryxdesign/core 7.24 MB packed (+9.3 kB); no new dependencies.
API changes: core +12 · ~0 · −0
Committed API report behind this build: cli 29 rows, core 36 rows; run pnpm api:report.
12 API changes (advisory)
| Package | Where | Signature | Usage | |
|---|---|---|---|---|
| + | core |
. · Components · component BaseTypeahead |
prop handleRef?: React.Ref<BaseTypeaheadHandle> |
<BaseTypeahead handleRef={…} /> |
| + | core |
. · Components · component BaseTypeahead |
prop menu?: BaseTypeaheadMenu |
<BaseTypeahead menu={…} /> |
| + | core |
. · Components · component Typeahead |
prop handleRef?: React.Ref<BaseTypeaheadHandle> |
<Typeahead handleRef={…} /> |
| + | core |
. · Components · component Typeahead |
prop menu?: BaseTypeaheadMenu |
<Typeahead menu={…} /> |
| + | core |
. · Types · interface BaseTypeaheadDialogMenuInfo |
interface BaseTypeaheadDialogMenuInfo |
import type {BaseTypeaheadDialogMenuInfo} from '@astryxdesign/core' |
| + | core |
. · Types · interface BaseTypeaheadHandle |
interface BaseTypeaheadHandle |
import type {BaseTypeaheadHandle} from '@astryxdesign/core' |
| + | core |
. · Types · interface BaseTypeaheadListboxMenuInfo |
interface BaseTypeaheadListboxMenuInfo |
import type {BaseTypeaheadListboxMenuInfo} from '@astryxdesign/core' |
| + | core |
. · Types · type BaseTypeaheadMenu |
type BaseTypeaheadMenu = { role: 'listbox'; render?: (info: BaseTypeaheadListboxMenuInfo) => ReactNode } | { role: 'dialog'; label: string; render: (info: BaseTypeaheadDialogMenuInfo) => ReactNode } |
import type {BaseTypeaheadMenu} from '@astryxdesign/core' |
| + | core |
./Typeahead · Also exported from an earlier entry point · BaseTypeaheadDialogMenuInfo |
BaseTypeaheadDialogMenuInfo (.) |
import {BaseTypeaheadDialogMenuInfo} from '@astryxdesign/core/Typeahead' |
| + | core |
./Typeahead · Also exported from an earlier entry point · BaseTypeaheadHandle |
BaseTypeaheadHandle (.) |
import {BaseTypeaheadHandle} from '@astryxdesign/core/Typeahead' |
| + | core |
./Typeahead · Also exported from an earlier entry point · BaseTypeaheadListboxMenuInfo |
BaseTypeaheadListboxMenuInfo (.) |
import {BaseTypeaheadListboxMenuInfo} from '@astryxdesign/core/Typeahead' |
| + | core |
./Typeahead · Also exported from an earlier entry point · BaseTypeaheadMenu |
BaseTypeaheadMenu (.) |
import {BaseTypeaheadMenu} from '@astryxdesign/core/Typeahead' |
Touched components checked; add ci:run-visual or ci:run-rtl to run the full suites.
Generated by PR Enrichment workflow | View full report
|
/approve-spec 15dd368 |
…n() opens it Addresses review on the menu config: - An outside press closes a dialog-role menu: the outside-press watch finds the layer from the element the input controls, in its own root, instead of the list the dialog replaces. - Only the handle opens a dialog-role menu; a search, focus load, focus or ArrowDown leaves it closed, so typing stays in the field. - The dialog role drives usePopover (role, dialogLabel, hasAutoFocus): the popover is the named, modal dialog, takes initial focus and restores it. The shared focus trap gains a restore fallback, used when the element focused at open is gone or was the page, and BaseTypeahead passes its input. - A pick that calls open() and stays a listbox returns focus to the input and loads the focus entries, or closes when there are none. - `hasNoResults` is now `isEmptySearch` (spec:AST-056 vocabulary); the outside-list warning runs in development only. - Records: contract-at-a-glance and compatibility say the change is additive; FR1, FR4 and AR1 are qualified by role; FR14 and FR16 state the open and pick rules; anatomy names Menu content and Menu dialog; verification rows name the new tests and the Chromium outside-press case.
|
/approve-spec 2d4bded |
There was a problem hiding this comment.
Changes requested. The dialog role now runs through the shared popover and focus trap, and the earlier outside-press, typing, focus-copy and keep-open findings are fixed; four issues remain:
- Miss: in a field with
hasEntriesOnFocus(the Menu story and theBaseTypeaheadMenublock), closing a dialog that a pick opened returns focus to the input and the field list opens again, so Escape needs two presses and a press outside leaves the list open; please keep that focus return from opening the list, deciding it in the close callback, and add tests for Escape,close()and an outside press after a pick. - The edit to
Tokenizer.spec.md:64splices the FR28 sentence into the middle of the'popover' | 'bottom-sheet' | 'adaptive'union and turns its escaped pipes into cell separators, so the rendered "Public contract" row loses the rest of the released contract; please restore that row and append the sentence after DEC-2. BaseTypeahead.tsx:1861readsprocess.env.NODE_ENVwithout a declaration, which failsprocessEnvTypes.test.tsin CI (test-ui (4/4)); please gate the warning on the dev flagutils/devWarning.tsalready owns, or declareprocessas that file does.- Miss: the new
BaseTypeaheadMenublock is missing frominternal/shadcn-registry/routes.lock.jsonand from the CLI search goldens, which failsdocsite-build,docsite-testandtest-node (3/4); please refresh the lock withUPDATE_SHADCN_ROUTE_LOCK=1 node apps/docsite/scripts/generate-data.mjsand update the goldens.
Smaller record and comment points are inline. The record fix needs a fresh /approve-spec on the new commit.
[Automated review]
… CI fixes - Closing a dialog-role menu that a pick opened (Escape, close(), an outside press) returns focus to the input without opening the list again, decided in the close callback, as a pick's own focus return already does. Tests cover Escape, close() and an outside press in a hasEntriesOnFocus field. - The outside-list warning gates on a declared build flag, as utils/devWarning.ts does, so processEnvTypes passes. - Tokenizer.spec: the Public contract row is main's, with the FR28 sentence appended; FR28 gains its Status cell. - BaseTypeahead.spec: AR6 says aria-controls names the layer that holds the dialog; FR14 names what the dialog render receives; FR15 says a focus return does not open the list. - The BaseTypeaheadMenu block joins the ShadCN route lock and the CLI search goldens.
|
/approve-spec fd768d0 |
There was a problem hiding this comment.
Changes requested. The earlier Escape and outside-press reopen, the Tokenizer contract row, the process.env type check, and the route lock and CLI goldens are fixed; three issues remain:
- A
close()that runs after an await (an editor that saves first) still reopens the field list in ahasEntriesOnFocusfield, because the reopen guard expires on a 0 ms timer before the focus return runs; please tie the guard to the focus return itself and add a test that closes after an await. - Miss: a Tokenizer token whose button calls
open()gets no focus back on Escape, because the field's click handler focuses the input before the deferred open records its opener, so Tokenizer FR28's "Escape returns focus to that token" does not hold; please record the opener whenopen()is called, or keep the wrapper click from refocusing the input on a token's own control, and add a Tokenizer test with arenderTokenbutton. - The pull request now counts 2,080 authored lines (2,152 changed, less 72 generated), over the 2,000-line limit with no exemption; please move the CLI
BaseTypeaheadMenublock, or the Typeahead and Tokenizer forwarding, into a follow-up pull request.
The review links the Chromium evidence for both behavior issues; one smaller comment note is inline.
[Automated review]
… open(); Tokenizer and CLI block move out - The dialog's close moves focus through the focus trap's new internal restoreFocusTo hook, so BaseTypeahead knows which focus is the return and keeps the list closed, however late close() runs (after an await). - open() records the element focused when it is called, and the menu returns focus there (usePopover's internal getOpener), so a click's own handlers that move focus first no longer take the opener. - To stay within the size limit, Tokenizer's forwarding (menu, onOpenChange, the handle's open and close, FR28) and the BaseTypeaheadMenu CLI block, with its route-lock and golden entries, move to follow-up pull requests. The Menu story keeps the example. - Test: close() after an await.
There was a problem hiding this comment.
Changes requested: the awaited close() focus fix works, and one size issue remains.
- The pull request is now 2,109 authored lines (1,945 before the latest commit), over the 2,000-line limit, and the stack exemption does not apply because #10624 and #10625 target feature branches rather than
mainand #10624 does not contain this head; bring this pull request to 2,000 authored lines or fewer, or make the stack hold so that each pull request targetsmainand contains the one below.
A dialog-role menu in a Typeahead with a value now returns focus to the Token's button for Escape, close() and an awaited close(), and the new cases fail on the previous revision and pass here. The record changes are approved for this head. Small leftovers can ride along: the changeset still ends with a semicolon, and the description mentions a CLI changeset that this pull request does not include.
[Automated review]
| // While the token shows, the input is hidden and out of the tab order, so a | ||
| // dialog-role menu returns focus to the token's button instead of the input. |
There was a problem hiding this comment.
Non-blocking (INV29): one 28-word sentence. Suggested: "The token hides the input and takes it out of the tab order. A dialog menu's focus return goes to the token's button."
|
/approve-spec 8c593c0 |
There was a problem hiding this comment.
Approved pending CI: build, test, docsite-test and the new Chromium spec have not run on this head yet.
The size request from the last review no longer applies, because the stack #10544 → #10624 → #10625 now holds and this pull request lands with it; the record changes are approved for this head, and the menu's listbox and dialog roles, its focus return and the open handle all have passing tests.
Optional cleanups: the changeset ends with a semicolon (.changeset/typeahead-menu.md:5), and four new comments run past the comment style's sentence length.
[Automated review]
There was a problem hiding this comment.
This pull request is reviewed as part of its stack; see the review on #10625.
…ctive option The list loads its entries after the click, and Enter and the arrow keys act on the active option, so the sibling pick tests raced the same way the Escape test did. A shared openList() waits for the 'Status' option to be marked active before any key. Test-only: no product source changes.
|
/approve-spec 1f58a0e |
There was a problem hiding this comment.
This pull request is reviewed as part of its stack; see the review on #10625.
…angeset sentence CI's strict promise-function-async rule rejected the non-async callbacks passed to expect.poll. Test and changeset text only.
There was a problem hiding this comment.
Changes requested: the menu config and the open handle behave as the approved BaseTypeahead and Typeahead records describe, and one size issue remains.
- At 2,126 authored lines this pull request is over the 2,000-line review limit, and the stack exemption does not apply because #10624's head does not contain this head's latest commit; merge this head into #10624 (and #10624 into #10625) so the declared stack holds again, or move the Typeahead forwarding into its own pull request.
Once the stack holds, the size is only a non-blocking note. The long comments flagged earlier at BaseTypeahead.tsx:990-993, :1041-1044, :1536-1537 and Typeahead.tsx:574-575 remain optional rewrites.
[Automated review]
The stack's top conflicted with main in the CLI goldens; main is merged at the bottom and carried up, so each PR's increment over the one below stays its own change.
|
/approve-spec 910d188 |
|
/approve-spec e26f00e |
There was a problem hiding this comment.
Changes requested: the menu config and the open handle behave as the approved BaseTypeahead and Typeahead records describe, CI is green on this head, and the size limit no longer applies now that the stack #10544 → #10624 → #10625 holds; one mechanical fix remains.
- Newly live check:
TypeaheadProps.menuandTypeaheadProps.handleRef(Typeahead) are outside this pull request's scope (BaseTypeahead), so name Typeahead in the scope, for examplefeat(BaseTypeahead, Typeahead): …or a## Scopesection withComponents: BaseTypeahead, Typeahead, since the approvedcomponent:TypeaheadFR11 already records the owner decision.
The earlier dialog-close finding is fixed on this head, and the comment-wording suggestions in the earlier inline threads are optional.
[Automated review]
|
/approve-spec e26f00e |
There was a problem hiding this comment.
Approved: the menu config and the handleRef open handle behave as the approved BaseTypeahead and Typeahead records describe, CI is green on this head, and the earlier scope finding is resolved now that the title names Typeahead.
- Optional: the long comments in the earlier inline threads (
BaseTypeahead.tsx:990-993,:1041-1044,:1536-1537andTypeahead.tsx:570-571) can still be split into short sentences that keep only the reason.
[Automated review]
|
/approve-spec e26f00e |
|
/approve-spec 44c9f6f |
There was a problem hiding this comment.
This pull request is reviewed as part of its stack; see the review on #10847.
Stack: #10544 → #10624 → #10625 → #10847
Merge group: #10544, #10624, #10625 (lands together; none merges alone)
Who this helps
Keyboard and screen-reader users of a custom typeahead. Builders who need a header, a hint, or an editor next to typeahead results build their own popup today, and PowerSearch's filter editor shows the result: after a person picks a field, focus lands in a popup with no role and no name, and Escape after editing a token sends focus to the search box instead of back to the token. With this change, BaseTypeahead keeps the menu's layer and lets the caller fill it through one
menuconfig that carries the role, the name and the content together. Owner decision: row 49, "49 A".What changed
menuon BaseTypeahead:{role: 'listbox', render}(the default,renderoptional) shows the result list.renderreceives the list, the query, the busy state, whether the search was empty (isEmptySearch), andclose, and places information such as a header or a key hint around the list. Anything a person acts on stays a result, so the arrow keys reach it. A control rendered outside the list draws one development warning (development builds only).{role: 'dialog', label, render}shows content that takes focus. The popover itself is the dialog: it runs throughusePopover's dialog role, so it is named bylabel, modal, takes initial focus and restores it. The input getsaria-haspopup="dialog"and no active descendant. Only the handle opens it: typing, focus or ArrowDown in the field don't. It does not close when the query empties, a load finds nothing, or the input loses focus; a press outside the field and the dialog closes it.close), focus returns to the element focused when the menu was asked to open (open()called, or the menu shown), or to the input when that element is gone. Three package-internal options on the shared focus trap andusePopovercarry this: the input fallback, the opener read atopen(), and a focus-return hook that lets BaseTypeahead keep the list closed when focus comes back to the input, however lateclose()runs.handleRefwithopen()andclose(), and the existingonOpenChangereports each change. There is no controlledisOpen(as in ComplexSelector), and noonTokenActivate.open()runs after the commit it is called in, so it uses the menu the caller rendered in the same event. A pick whoseonChangecallsopen()keeps the menu open, so switching the list to a dialog keeps the same layer on the same anchor. If the menu stays a listbox, focus returns to the input and the list loads its focus entries, or closes when there are none.menuandhandleRef. While its token shows, a dialog menu's close returns focus to the token's button (BaseTypeahead's restore point asks the field for that stand-in through an internal context), for Escape,close()and aclose()after an await. Tokenizer's forwarding (with FR28 and token focus return) is feat(Tokenizer): forward BaseTypeahead's menu, onOpenChange and open handle #10624, and the CLI block is feat(cli): a BaseTypeaheadMenu block #10625, in the same merge group.Menustory builds a filter field: a heading and a key hint around the list, and a pick or a filter button opens a dialog that edits the value. The matching CLI block is feat(cli): a BaseTypeaheadMenu block #10625.menuandopen handleconcept rows, FR13–FR16, AR6, ORD3, an allowed-variation line, DEC-1 (row 49 A), DEC-2 (nocontrolRefon TextInput: that route handles none of the accessibility a typeahead needs; a custom typeahead uses BaseTypeahead withanchorRefandmenu), and the not-decided note: "menu styling overrides may be added later (for example part styling or theme targets); out of scope now". The contract table and compatibility now say the change is additive; FR1, FR4 and AR1 are qualified by role; the anatomy names Menu content and Menu dialog.Changeset:
[feat]patch for Core.Verification
Real Chrome (a local Storybook build of this branch, the Menu story, Neutral theme, headless Chromium on this machine, 1280 and 375 px):
aria-haspopup="dialog".Tests:
BaseTypeahead.menu.test.tsxcovers:open()and stays a listbox (reload, or close with focus in the input);close(),close()after an await, an outside press) leaving the list closed;BaseTypeaheadMenu.a11y.chromium.spec.tsruns the keyboard, role-switch, focus-return and outside-press cases in pr-a11y. The Typeahead, Tokenizer, PowerSearch, Popover, hooks and processEnvTypes suites pass (2127).Other checks: lint; the Core and CLI template typechecks show no errors in the changed files; knowledge; the Core build; and the API report (only this change's rows).
Writing rubric results
Covers
component:BaseTypeaheadFR13–FR16, AR6, ORD3, DEC-1 and DEC-2, andcomponent:TypeaheadFR11.R1 narration: none; each line states what the component does.
R2 research: none in the records; the measurements are here.
R3 evidence: verification cells name tests and the story spec, not pull requests.
R4 rejected alternatives: DEC-1 records the spread-props layer and typed layer options; DEC-2 records a
controlRefon TextInput.