Skip to content

feat(Typeahead): add isLoading and changeAction - #5999

Draft
AKnassa wants to merge 11 commits into
meta:mainfrom
AKnassa:ak-5941-typeahead-transition-action
Draft

AKnassa wants to merge 11 commits into
meta:mainfrom
AKnassa:ak-5941-typeahead-transition-action

Conversation

@AKnassa

@AKnassa AKnassa commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

What this does

Typeahead can now show that its value is busy, and can run a save step after a selection. isLoading marks the value as resolving or saving. changeAction runs after onChange, inside a React transition, and the field shows the proposed value as busy until the parent's value accepts or replaces it. A controlled value that arrives while the Action is still pending wins at once.

Why

The input-field family contract gives every field the same two ideas: a busy value (FR5) and a Transition Action (FR6). Selector, MultiSelector, TextInput and others already have them. Typeahead only knew how to show a search in flight, and a caller who wanted "saving…" after a pick had nothing to reach for. #5941 lists this as a gap. AST-001 also matters here: isLoading must never be read as "the options are still loading", and this keeps the two meanings apart.

What changed

  • New optional isLoading prop: the end-lane Spinner shows and the combobox carries aria-busy. The search source and its results are untouched.
  • New optional changeAction prop, called with the same item (or null) that onChange receives. onChange still runs first; the Action runs in a transition; the token shows the proposed item at once; if the parent never accepts it, the field falls back to the accepted value, and a replacement arriving mid-Action shows immediately. Clearing goes through the Action too.
  • One Spinner and one aria-busy for both meanings: a search in flight and a busy value never show two indicators (FR7).
  • The busy signal reaches the combobox through a package-internal context rather than a new public prop on BaseTypeahead, so the public surface grows by exactly these two props.
  • The clear button keeps following the accepted value, not the proposed one, as Selector does.
  • The disabled-reason guards this PR first added are now on main (a disabled field opens no list and picks nothing), so the PR no longer carries them.
  • Callers that pass neither prop see one change: when the token and the input swap places, focus moves to the one that stays (see the maintainer follow-up).
  • Docs: prop entries, the component spec states the API delta and cites family:input-fields FR5–FR7 and DEC-2/DEC-3 for the shared semantics while recording only Typeahead's mappings, the family adoption table row, two Storybook stories ("Input busy", "Transition action"), and a patch changeset.

How to see it

Storybook → Typeahead → "Input busy" and "Transition action". In the second story, pick a fruit: the token appears at once with the Spinner, and settles about a second later. Screenshots of the busy, pending and settled states follow in a comment.

Evidence

The input busy: isLoading and changeAction suite has 23 tests (file total 105; a post-open review round added three focusable-disabled regression tests to the disabledMessage suite — Tab's keydown dismissal, the Escape invariant, and the option click on a menu left open by a mid-flight disable — each kept red under a one-line mutation; a second round rewrote the parent-replacement test so the replacement wins before the old Action resolves, and three one-line mutations of the display rule each turn a test red). The first 8 were red before the change. The 15 edge-case tests pass on the change as written, so each was kept only after a one-line mutation made it fail: gating the clear button on the proposed value, passing the accepted value to the listbox instead of the proposed one, swallowing a rejected Action in a try/catch, awaiting a void Action as a promise, dropping the Spinner's accessible name, and dropping the InputGroup end lane each turn one specific test red.

Covered: a second selection while the first Action is pending; clearing mid-Action; busy holding while either isLoading or an Action is active and releasing only when both do; isLoading turning off while a search is still in flight keeps the single Spinner; the proposed item is aria-selected in the listbox; Escape in edit mode restores the proposed token while pending and nothing once withdrawn; a parent replacing the value mid-Action; every Action path blocked while focusable-disabled; a rejected Action reaching the nearest error boundary once, with no unhandled rejection; a synchronous Action leaving no stranded busy state; unmounting mid-Action; the Spinner named from the i18n catalog; one Spinner inside an InputGroup row; and a composing (IME) Enter not running the Action.

Extending the focusable-disabled test with ArrowDown then Enter turned it red on the hole above and green after the guard.

One thing worth knowing for future tests: React's async-action scope is shared, so a test that leaves an Action unsettled stalls every later transition in the file. The suite now settles every deferred Action in afterEach.

Local checks, all on top of the current upstream main: Typeahead, BaseTypeahead, Tokenizer, Selector and InputGroup suites (407 tests), core typecheck and docs typecheck, eslint, prettier, and the knowledge, changeset and SYNC checks.

Pre-existing behaviour seen along the way, not changed here

  • Leaving edit mode after the proposal was withdrawn keeps the injected label as the query text. Same as the existing controlled path.

Rubric

Triage: new API surface · non-breaking · low blast radius → deep path (the API shape is the maintainers' call; this is the shape #5941 and family FR5–FR7 ask for) · checks: §1 A1–A7/A11–A12, §3 P1–P7/P15–P18, §7 C1–C8/C11, §8 X5/X9–X12, §9 I1–I5, §3 P11–P12 · X20 changeset, §5b screenshots

Part of #5941 (Typeahead isLoading + changeAction checkbox). The busy-context change in busyIndicatorLane.tsx and BaseTypeahead.tsx is byte-identical to the Tokenizer PR for the same issue, so whichever lands second rebases clean.

https://claude.ai/code/session_01N5RkmXVgx725F6rqZTGecR

Maintainer follow-up

(Posted by Cindy's agent on her behalf.) Carried on this branch with the author's commits kept. Exact head: db55cd3.

  • Merged main (conflicts in BaseTypeahead.tsx, Typeahead.tsx, Typeahead.test.tsx, the stories and the family table). Since this was opened, main makes the Spinner decorative with a name, names the token button by the field label and the value, enters edit mode inside the tap, and blocks a disabled field's list and picks. The changes here now sit on top of that. The disabled-reason guards this PR added are dropped because main already has them.
  • The Typeahead record moved to docs/specs/components/Typeahead/ on main. Its additions now sit there: FR11 (input busy and the Transition Action, with the clear button following the accepted value), FR12 (the focus handoff), AR4, the Compatibility section, and two verification rows.
  • The focus handoff no longer opens suggestions or reports onOpenChange(true) on a hasEntriesOnFocus field. Two new tests cover both withdrawal paths (the parent clears the value, and an Action is not accepted). Both fail without the change.
  • The handoff uses the shared focus-return path (noteFocusWithin, moveFocusLeftBehind, useFocusLeavingChange), per the latest review, so it reads the field's own document, also in an iframe or a Picture-in-Picture window. The record's FR11 and FR12 rows have their basis, and their verification rows are in the verification map.
  • A token that returns because the input lost focus takes no focus. Without this, main's blur tests saw a second blur.
  • Compatibility and the Changeset list the one change for callers who pass neither prop: the focus handoff, including a token that appears while the person types.
  • vitest run packages/core/src/Typeahead packages/core/src/Tokenizer: 453 passed. Core tsc, eslint (no new findings), check:knowledge, check:changesets and the comment-provenance baseline pass.
  • isLoading and changeAction are new public props, so they wait for the project owner's decision. The PR stays a draft until then.

Writing rubric results

Run over the docs/specs/components/Typeahead/Typeahead.spec.md additions (Contract at a glance rows, Compatibility, Public concepts, FR11, FR12, AR4, the family:input-fields relationship, and two verification rows) and the docs/families/input-fields.md Typeahead adoption row.

  • R1 narration: none. The text is present tense, with no proposes, we decided, previously, a port of or used to.
  • R2 research in the record: none.
  • R3 evidence naming a change: none. The verification rows name test suites and cases.
  • R4 rejected alternatives over one line or outside a decision: none.
  • R5 pull request or issue references remaining: none. The added lines contain no # followed by digits, /pull/ or /issues/.
  • R6 ruled open questions still listing options: none.

@vercel

vercel Bot commented Sep 4, 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 9, 2026 11:27am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 4, 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 needs:spec-owner-review Current knowledge records await owner approval labels Sep 4, 2026
github-actions Bot added a commit that referenced this pull request Sep 4, 2026
@github-actions

github-actions Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

Current run: The current CI run concluded skipped. Current analysis is unavailable.


Generated by PR Enrichment workflow | View current CI run

@cixzhang cixzhang 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.

Please reduce duplication with the current family:input-fields contract. The family already owns the meaning and ordering of isLoading and changeAction; this component record should link to those exact requirements/decisions rather than restating their general semantics in Compatibility, Public concepts, and the verification narrative. Keep only Typeahead-specific adoption: (item: T | null) mirrors onChange; source-busy and value-busy share one Spinner and combobox aria-busy; selection and clear route through the family Action order; and focused tests prove those mappings. Preserve the current-anatomy inventory and the separate open theming-reachability question. This keeps one normative owner and makes the component record easier to review.

@cixzhang
cixzhang dismissed their stale review September 5, 2026 00:32

Replacing this summary-only review with contributor-facing inline feedback.

@cixzhang cixzhang 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.

Thanks for closing the Typeahead family gap and preserving the existing no-new-prop path. I left one writing comment to keep the family contract as the single normative owner.

`family:input-fields` (FR5–FR7, DEC-2, DEC-3), not Typeahead-owned concepts.
Typeahead owns only the Action's argument shape, which mirrors `onChange`:
`(item: T | null)`. Search busy stays BaseTypeahead-owned; both meanings share
the one end-lane Spinner and the combobox `aria-busy`.

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.

Thanks for mapping the shared input-field behavior onto Typeahead so explicitly. Could we make this section shorter by citing family:input-fields FR5–FR7 and DEC-2/DEC-3 for the general isLoading / changeAction semantics, then keep only Typeahead’s mapping here: (item: T | null), one shared Spinner + combobox aria-busy, and the selection/clear verification? That keeps the family record as the single owner and makes this component adoption easier to scan.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 1a9fee6. Compatibility, Public concepts, the verification row and narrative, and the Decision log now cite family:input-fields FR5–FR7, AV4 and DEC-2/DEC-3 and keep only Typeahead's mappings. The family is also linked in the non-goals and Family and system relationships bullets as in Selector's record, and the Accessibility contract records the two combobox deltas instead of denying any change. Rebased on main so CI picks up #5994; the spec gate needs /approve-spec 1a9fee6e6 again.

@cixzhang
cixzhang dismissed their stale review September 5, 2026 00:33

Spec review found no substantive blocker; keeping the inline writing suggestion as non-blocking. Implementation review remains separate.

@cixzhang

cixzhang commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Thanks for adding the Typeahead adoption record and connecting it to the input-field family. The specification direction has no substantive blocker from this pass. The inline deduplication suggestion is editorial and non-blocking. This is a specification review only; the implementation at this head still needs a separate code and behavior review before it can be approved.

@cixzhang

cixzhang commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

/approve-spec

@cixzhang

cixzhang commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Thanks for adding the Typeahead adoption record. The specification is approved at this exact head; the inline writing suggestion is non-blocking. The implementation and its failing CI are being routed for a separate code and behavior review.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

That /approve-spec comment did not change spec-owner-approval: it did not name a commit.

The gate only accepts the exact current head, so post this instead:

/approve-spec 37ebf3c1f1f0607d45015df7e50d096286781ecc

A new commit invalidates the command, so repeat it after any push.

Adopt the input-field family's busy and Transition Action contracts.
isLoading marks the value as busy (FR5): the end-lane Spinner shows and
the combobox carries aria-busy while the search source and its results
stay untouched (AST-001). changeAction runs after onChange with the
same item, in a transition, on selection and clear, with the proposed
item shown as the token until value catches up (FR6). A search in
flight and a busy value share one Spinner and one aria-busy (FR7): the
busy signal reaches BaseTypeahead through a package-internal context,
so no public prop is added there. The clear button follows the
accepted value like Selector's.

Also closes a keyboard path that slipped through while the field is
disabled with a reason (FR4): ArrowDown could open the entries shown on
focus and Enter select one. The base key handler now returns while
disabled; that hunk is byte-identical to the Tokenizer change for
meta#5941.

The component spec records the API delta per AST-002 FR12/FR13, and
23 tests pin the behaviour: Action ordering, concurrent Actions,
rollback, edit mode during a pending Action, the error boundary path,
unmount while pending, one Spinner in an InputGroup row, and every
Action path blocked while focusable-disabled.

Part of meta#5941 (Typeahead checkbox).

Claude-Session: https://claude.ai/code/session_01N5RkmXVgx725F6rqZTGecR
The Typeahead record restated the input-field family's isLoading and
changeAction semantics in Compatibility, Public concepts, the Input busy
verification row, the narrative after the verification map, and the
Decision log. Those sections now cite family:input-fields FR5-FR7, AV4 and
DEC-2/DEC-3 and keep only Typeahead's adoption: the Action receives what
onChange receives, (item: T | null); selection and clear both follow the
family's FR6 order; input busy and BaseTypeahead's source busy share the
one end-lane Spinner and the combobox aria-busy.

The family is also linked where the template and Selector's record put it
(a non-goals bullet and a Family and system relationships bullet), the
Compatibility bullet names the family's FR4 so it is not read as the
record's own FR4, and the Accessibility contract records the two combobox
deltas the PR makes instead of a pre-PR sentence that denied any change.
review_triggers now lists public-api, behavior and accessibility like the
sibling records that carry a public prop and an accessibility row.

Anatomy inventory and OQ1 are unchanged.

Review: meta#5999 (comment)
@AKnassa
AKnassa force-pushed the ak-5941-typeahead-transition-action branch from 37ebf3c to 1a9fee6 Compare September 5, 2026 03:15
github-actions Bot added a commit that referenced this pull request Sep 5, 2026
@AKnassa
AKnassa marked this pull request as ready for review September 8, 2026 01:27
…sable-disabled

The disabled key guard swallowed Tab, skipping the keydown dismissal
that stops Chrome dropping focus to <body> when the open menu hides
during focusout. Tab now passes through; Escape needs no passthrough
because the layer stack routes an unclaimed press to the topmost layer.
Also closes the pointer half of FR4: handleSelect now ignores clicks
while disabled, so a menu left open by a mid-flight disable cannot
commit a selection. Three regression tests, each kept red under a
one-line mutation; changeset wording updated.
@AKnassa

AKnassa commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

Pushed ea16370 with a small FR4 hardening round from a self-review: the disabled key guard now lets Tab through so its keydown dismissal still runs, and handleSelect ignores clicks while disabled so a menu left open by a mid-flight disable cannot commit a selection. Three mutation-proven regression tests. The spec file is unchanged; the gate now needs /approve-spec ea16370.

@cixzhang cixzhang 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.

A parent can replace value while an Action is pending, but the field keeps showing the stale proposal and aria-busy until that old Action settles (Typeahead.test.tsx:2653–2684). External validation or another controlled update therefore leaves users looking at a value the app has already replaced. Please make the incoming controlled value immediately replace the optimistic token and end that proposal’s busy state, then update this test to prove Banana appears before the old Action resolves.

Thanks for covering the busy/search overlap and disabled paths.

[Reviewed by Robohands]

…ransition-action

# Conflicts:
#	packages/core/src/Typeahead/BaseTypeahead.tsx
@AKnassa

AKnassa commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

Fixed in c3b8b87, with main merged in (e3a35fd). The pending proposal is now the optimistic state and carries the value it was proposed against, so it shows only while the parent still holds that value: a replacement arriving mid-Action wins at once and ends that proposal's busy state, and stacked proposals still keep the latest. The test now proves Banana shows before the old Action resolves. Selector, MultiSelector, TextInput and DateInput on main keep the settle-first behavior; I can take that as a family follow-up. One verification-row cell in the spec changed, so the gate needs /approve-spec e3a35fd again.

github-actions Bot added a commit that referenced this pull request Sep 15, 2026

@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.

Thanks for closing the Typeahead family gap — isLoading, changeAction, the single shared busy indicator, and the disabled-selection guards all line up with the input-field family contract, and a different controlled item now replaces a pending proposal immediately as requested.

Two fixes are needed in the new pending-Action lifecycle before this is ready:

  • Proposal identity: the proposal is retained by object reference (proposal.base === value), so if a parent re-renders with a fresh object for the same item id, the proposed token and busy state disappear while the Action is still running. Please compare by item id (including the null case) and add a same-id regression next to the replacement test.
  • Rollback focus: when an Action is not accepted, focus is stranded — settlement removes the focused proposed token and focus falls to body after a selection, and after a clear the restored token leaves focus on the hidden tabIndex=-1 input. Please hand focus to the surviving visible control in both directions and assert it in tests.

The focused suites (111 tests), typecheck, and knowledge check otherwise pass.

[Automated review]

Resolved conflicts:
- docs/families/input-fields.md: took upstream's reformatted adoption
  table (meta#6407 widened the Recorded exception column) and re-applied this
  PR's Typeahead row (`isLoading`, `changeAction`, ..., source busy |
  search lifecycle is component-owned), then ran prettier on the table.

BaseTypeahead.tsx and Typeahead.test.tsx auto-merged (picking up meta#6370's
searchSource invalidation during render).
Addresses astracat-bot's review of meta#5999.

F1 (proposal identity): the pending proposal was kept only while
`proposal.base === value` by reference, so a parent re-rendering the same
item as a fresh `{id, label}` object dropped the proposed token and
`aria-busy` mid-Action (a regression from the replacement fix). Proposal
retention and value busy now compare by item `id` (`isSameItem`, null
included), the key BaseTypeahead already uses for the selected option. A
different id still replaces the proposal at once.
Test: "keeps the proposal and busy state when the parent re-renders the
same item as a fresh object" - red before: token "Banana", expected
"Apple"; green after.

F2 (rollback focus): when the token and the input swap places, focus now
moves to the one that stays. A callback ref snapshots whether the token
held focus in its cleanup (React runs it before removing the node), and a
layout effect keyed on `showToken` transitions (not mount) hands focus to
the input when a focused token is withdrawn, or to the restored token when
it returns over the focused input. The post-selection rAF shares the new
`focusToken` helper. Spec Accessibility contract and changeset now state
the focus handoff.
Tests: "returns focus to the input when an unaccepted selection Action
withdraws the focused token" (red before: focus on <body>), "moves focus
to the restored token when a clear Action is not accepted" (red before:
focus stayed on the hidden tabindex=-1 input), and "hands focus to the
input when the parent clears the value under a focused token" (red
before: <body>; the pre-existing plain-parent case). Each F2 branch was
mutation-checked: removing either fails exactly its test.
Follow-up to the F2 focus handoff (astracat-bot's review of meta#5999).

F2 (rollback focus): the "focused token withdrawn -> focus the input" rule
also fired when the token left because the user entered edit mode (Enter or
Space on the focused token, or a click that focuses it first). Focus reached
the input in the layout effect, a frame before edit mode writes the label
into the query, so with `hasEntriesOnFocus` the base saw an empty query, ran
`bootstrap()` and opened the entries with the first one active under the old
label; a second Enter in that window selected it. Edit mode already owns that
focus move, so the handoff now skips it (`!isEditing`); `wasTokenShownRef`
keeps the effect transition-only. Action rollbacks and a parent clearing the
value still hand focus to the input, so the spec and changeset wording is
accurate as written.
Test: "leaves focus to edit mode when the focused token is activated" - red
before: bootstrap called once right after activating the token, and with
that assertion skipped a second Enter called onChange(Apple) while editing
Banana; green after, including focus and the label on the input after the
frame.
@AKnassa

AKnassa commented Sep 26, 2026

Copy link
Copy Markdown
Contributor Author

Pushed 79e759e. Main is merged in (899ff96). The only conflict was the reformatted table in docs/families/input-fields.md, where I re-applied the Typeahead row.

  • Proposal identity (a21aea7): the pending proposal and aria-busy now compare by item id, with null handled. That is the same key BaseTypeahead uses for the selected option. If a parent re-renders the same item as a fresh {id, label}, the proposal stays; a different id still replaces it at once. I added a test next to the replacement test.
  • Rollback focus (a21aea7): when the token and the input swap places, focus moves to the one that stays. A withdrawn focused token (Action not accepted, or the parent clearing the value) hands focus to the input. When a clear Action is not accepted, the restored token takes focus. Tests cover both directions and the parent-clear case. You were right that the selection case is new with this PR. The description's "behaves exactly like the existing controlled path" line is wrong, and I still need to correct it.
  • Edit mode (79e759e): the handoff now skips entering edit mode, which already manages focus. Without that, hasEntriesOnFocus opened the entries under the old label. There's a regression test for it.

Still open: with hasEntriesOnFocus, a clear Action that is not accepted leaves the entries list open under the refocused token. It was already open before, over the hidden input. Closing it needs a hook in BaseTypeahead, so I'd rather handle it in a follow-up if that's OK.

The spec's Accessibility contract changed, so @cixzhang, this needs /approve-spec 79e759e1c66043ca3680694c4cb2fdac825d1649 and a re-review when you have a moment.

@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.

Thanks for the follow-up round — both issues from the last review are fixed, and this now lines up with the input-field family contract.

  • Proposal identity: retention and busy now compare by item id (with null handled), so a parent re-rendering the same item as a fresh object keeps the proposed token and aria-busy while the Action runs, and a different item still replaces the proposal at once. The same-id regression sits next to the replacement test.
  • Rollback focus: the token/input swap now hands focus to the control that stays — input after an unaccepted selection or a parent clear, restored token after an unaccepted clear — and the extra commit correctly leaves edit mode to own its focus move, with regression tests for each direction.

Two small things to tidy up, neither blocking:

  • The PR description's pre-existing-behaviour note still says a withdrawn focused token drops focus to the page; as you noted, that line needs updating to match the new handoff (the changeset and component record already state it correctly).
  • Please keep the disclosed hasEntriesOnFocus follow-up tracked: a clear Action that is not accepted leaves the entries list open under the restored token. The same state is reachable today through a rejected plain clear, so it does not block this PR.

The component record's spec-owner approval for this head is still pending, which remains the process gate before merge.

[Automated review]

@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.

Thanks for the careful work here: isLoading, changeAction, the shared Spinner and aria-busy, the immediate replacement of a pending pick, and the disabled-field guards line up with the input-field family contract. Approval waits on a maintainer decision about two rules the Typeahead record adds that the family contract does not state: focus moving to whichever of the token and the input stays when they swap (which also reaches callers using neither new prop), and the Clear button following the accepted value while an Action is pending. Whatever that decision, please also:

  • keep the focus handoff, if it stays, from opening the suggestions and firing onOpenChange(true) on hasEntriesOnFocus fields, with tests for both withdrawal paths;
  • list every behaviour change for callers without the new props in the record's Compatibility section and the changeset, including blocked option clicks and focus moving to the token when a parent sets a value while the user types;
  • merge the current main, which conflicts in BaseTypeahead.tsx, Typeahead.tsx and Typeahead.test.tsx.

[Automated review]

Fit isLoading and changeAction to main's Typeahead: the decorative named
Spinner, the field-named token button, the in-tap edit mode, and the
disabled guards main already ships. The focus handoff opens no
suggestions on a hasEntriesOnFocus field, and a token that returns on
blur takes no focus. The record moves to its component folder with FR11
and FR12. The Changeset lists the one change for callers without the new
props.

Co-authored-by: AK <[email protected]>
@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Nov 9, 2026
@cixzhang
cixzhang marked this pull request as draft November 9, 2026 10:49
@cixzhang cixzhang added ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) labels Nov 9, 2026

@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.

Thanks for the careful work here: isLoading, changeAction, the shared Spinner and aria-busy, the immediate replacement of a pending pick, and the quiet focus handoff on hasEntriesOnFocus fields line up with the input-field family contract. Approval waits on an engineering owner's decision, because the Typeahead record now adds FR11, FR12 and AR4 and no current record admits isLoading and changeAction for Typeahead: the owner approves or changes the two props, the rule that Clear follows the accepted value while an Action is pending, and the focus handoff that also reaches callers using neither prop. An engineering owner records that decision by commenting /approve-spec ce97f6cc40660f1c95c91714aecc5e444dce2021; the author can do so only if they are an engineering owner. Whatever the decision, please also fix:

  • Newly live check: the focus handoff in Typeahead.tsx re-implements the shared noteFocusWithin/moveFocusLeftBehind path (utils/focusReturn.ts, driven by useFocusLeavingChange) and isFocusDetached with reads of the global document, so it misses focus in an iframe or Picture-in-Picture window; please call the shared helpers instead.
  • In Typeahead.spec.md, the FR11 and FR12 verification rows sit inside the Behavioral and layout contract table, leaving FR11 and FR12 without a Basis and the Verification map without their rows; please move them.

[Automated review]

The focus handoff now notes focus before the swap and moves it with
noteFocusWithin and moveFocusLeftBehind, so it reads the field's own
document, also in an iframe or a Picture-in-Picture window. The record's
FR11 and FR12 rows get their basis, and their verification rows move to
the verification map.

Co-authored-by: AK <[email protected]>

@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.

Thanks for moving the focus handoff onto the shared focus-return path and putting the FR11 and FR12 verification rows into the Verification map; with that, the implementation shows no blocking defect. Approval waits on an engineering owner's decision, because the Typeahead record adds FR11, FR12 and AR4 and no current record admits isLoading and changeAction for Typeahead: the owner approves or changes the two props, the rule that Clear follows the accepted value while an Action is pending, and the focus handoff that also reaches callers using neither prop. An engineering owner records that decision by commenting /approve-spec db55cd3e2b4c68d675fddcf09daeede8d4fcd7e4; the author can do so only if they are an engineering owner. One small, non-blocking wording note is left inline.

[Automated review]

Comment on lines +589 to +591
// token present on mount leaves autofocus alone. Escape and blur have
// already moved focus off the input by the time the token returns, and a
// token that returns because the input lost focus takes none. Edit mode

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.

Non-blocking: Escape does not move focus off the input before the token returns. The Escape handler leaves focus there, and this handoff is what moves it to the token. A shorter version: "When the token and the input swap, focus moves to the one that stays. A token present on mount takes no focus. A token that returns on blur takes none. Edit mode focuses the input itself."

@cixzhang
cixzhang dismissed their stale review November 18, 2026 21:23

(Posted by Cindy's agent.) Dismissed as stale on the owner's decision: this review is on an outdated head. Please re-review the current head if concerns remain.

This branch was successfully deployed

1 active deployment
Preview — db55cd3e Deployed Nov 9, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) 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 needs:design-review Affects visuals — Design should review needs:spec-owner-review Current knowledge records await owner approval

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants