Skip to content

feat(core): minQueryLength — hold the typeahead search until the query is long enough - #5385

Merged
freddymeta merged 8 commits into
mainfrom
feat/typeahead-min-query-length
Aug 27, 2026
Merged

freddymeta merged 8 commits into
mainfrom
feat/typeahead-min-query-length

Conversation

@freddymeta

@freddymeta freddymeta commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Closes #5384.

The problem

BaseTypeahead searches every non-empty query, and performSearch opens the layer whenever searchQuery.length > 0 — including when the source came back empty. On a remote source that means a request per keystroke, and, worse, a menu reading No results found after one character, when the truth is that one character matched too much to be worth asking.

A SearchSource can already refuse a short query (q.length < 3 ? [] : fetch(q)), which covers the network. It cannot close the menu: the open decision lives inside the component and there is no controlled isOpen, no imperative handle, and onOpenChange only reports. The one lever left to a wrapper is CSS-hiding Astryx's own popover, which is worse than the empty state it hides.

The change

minQueryLength?: number on BaseTypeahead, forwarded by Typeahead and Tokenizer.

<Typeahead
  label="Assignee"
  searchSource={userSource}
  value={assignee}
  onChange={setAssignee}
  minQueryLength={3}
/>
query length minQueryLength={3} default (1)
0 untouched state; hasEntriesOnFocus decides, as today unchanged
1–2 no search, no live-region announcement, menu closed, in-flight search cancelled unchanged — searches
3+ searches and opens, as today unchanged

The default is 1, which is exactly today's behaviour — every non-empty query searches, and every existing call site renders identically. The prop is the opt-in.

Two follow-on details, both deliberate:

  • ArrowDown does not fall back to bootstrap entries while a below-threshold query sits in the input. The closed-menu ArrowDown branch bootstraps when hasEntriesOnFocus and there are no results; below the threshold that would open a menu of default suggestions that ignore the two characters already typed. Gated on the same predicate, so with the default it never fires differently.
  • The live-region announcement is gated with the search, not separately — the "no results found" a screen reader hears today after one keystroke is the same defect from the other side.

A stranded loading state, fixed on the way

Predates this prop and reproduces on main. Abandoning an in-flight search — by emptying the field, by falling below the threshold, or by selecting an item while the next search is still out — bumps the search generation, which makes that search's own finally decline to clear the loading flag. The field kept reporting Loading to assistive technology until some later search happened to settle. Both abandonment paths now clear it themselves.

hasCreate is not gated by the threshold

Raised in review, and right: minQueryLength is a search threshold, and creating costs no fetch. A field that can create QA should not stop being able to just because a search for QA would match too much.

The Create entry used to be built inside filteredSource.search, which put it behind the gate. It is now derived from the typed text on a separate path, so with minQueryLength={3} typing QA offers Create "QA" and Enter commits it while the search source is never called.

That path is __queryEntries on BaseTypeaheadProps — underscored and @internal deliberately. BaseTypeaheadProps is re-exported from the package entry point, so an ordinary name would ship as public API at the next cut with Tokenizer as its only caller. Same treatment as DefinedTheme.__inputTokens.

One consequence worth naming: the Create entry is appended after results are cut to maxMenuItems, so with hasCreate a full menu shows one option more than the cap — 11 where main showed 10. That is the intended reading of the cap: it bounds how many results a menu shows, and creating is a separate capability that should not be crowded out by them. Pinned by a test, since it is exactly the kind of thing a later refactor would "tidy" back into the slice, and documented on both maxMenuItems and minQueryLength.

Naming

minLength is what jQuery UI (default 1) and PrimeReact (default 1) call it, and I started there. On a component that renders an <input> it reads as the native minlength validation attribute — a different length of a different string — which is exactly the collision API Conventions says not to create. minQueryLength names the string being measured, and matches PowerSearchField.typeaheadMinQueryLength, which is this same concept already in the repo one layer up.

Deliberately not in this PR

No "type N more characters" hint. Below the threshold the field looks untouched. A hint would be a new user-facing string, a new i18n key across 29 locales, and a design decision about a state the design system has never had — that is the team's call, and it is the open question in #5384. Consumers who want one today can put it in description. Whichever way that lands, it composes with this prop rather than replacing it.

Not wired into Selector / MultiSelector / CommandPalette. They render BaseTypeahead over local, already-loaded item lists where the threshold buys nothing.

Verification

  • Typeahead + Tokenizer suites: 127 tests pass, of which 9 are new.
  • pnpm lint:strict — 0 errors in the touched files. tsc --noEmit on @astryxdesign/core — clean. pnpm build — clean.
  • Changeset: [feat] → patch (0.x).

The new tests carry their own controls rather than only asserting absence:

  • "does not search below the threshold" then types the third character and asserts the same harness does see search('App') and aria-expanded="true" — a permanently-closed menu could not pass it.
  • "still offers Create below minQueryLength" is paired with a negative control without hasCreate: same query, same threshold, menu stays shut and no No results found is announced for a query nobody searched.
  • A token already held still gets no Create entry below the threshold.
  • The first character still searches when the prop is unset.

No visual change — the styling is untouched; the only difference is whether an existing popover opens, and what it holds.

Docs

BaseTypeahead, Typeahead and Tokenizer .doc.mjs (en + zh + dense), a Minimum Query Length story, and an argTypes control.

… is long enough (#5384)

BaseTypeahead searched every non-empty query and opened the layer whenever
the query was non-empty, so a remote source saw a request per keystroke and
the user saw "No results found" for a one-character query that matched too
much rather than too little. A SearchSource can already refuse a short
query, but the open decision is internal — nothing outside the component
could keep the empty state closed.

minQueryLength (default 1 — today's behaviour) gates the search, the
result-count announcement and the menu. Forwarded by Typeahead and
Tokenizer; ArrowDown does not fall back to bootstrap entries while a
below-threshold query sits in the input.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 24, 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 24, 2026
@vercel

vercel Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview Aug 27, 2026 1:12am

Request Review

@github-actions

github-actions Bot commented Aug 24, 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.

Modified Components

Tokenizer (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 688 -
Complexity N/A Very High (102) -
Typeahead (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 1222 -
Complexity N/A Very High (174) -

Bundle Size Summary

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

Accessibility Audit

Status: 1 accessibility violation(s) found — 1 serious.

Tokenizer - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 2/21 stories · Learn more
    • WCAG: 1.4.3 (Level AA)

Visual Regression

Status: No visual change across 28 compared shot(s). 194 shot(s) have no baseline yet and were not compared.


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

@freddymeta
freddymeta marked this pull request as ready for review August 24, 2026 14:53
cixzhang added a commit to cixzhang/astryx that referenced this pull request Aug 24, 2026
cixzhang added a commit to cixzhang/astryx that referenced this pull request Aug 24, 2026
default: '10',
},
{
name: 'minQueryLength',

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.

Still English in docsZh. BaseTypeahead's is translated.

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.

Translated in 57cde40f8 — docsZh now reads 查询搜索源前的最小查询长度…, and it has since picked up the hasCreate carve-out too, so the Chinese entry says the same thing the English one does rather than a shorter version of it.

@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 this, and for the RFC first — the shape is right.

One thing to fix. The below-threshold branch bumps the search generation but
never clears isLoading, so the in-flight search fails its own check in
finally. Backspace from three characters to two on a remote source and the
field spins forever — "Loading" in the a11y tree until the third character goes
back in. Without the prop the same gesture clears in ~1.2s.

setResults([]);
setHasSearched(false);
setIsLoading(false);
interrupted mid-search search allowed to finish
stuck clean

"Ap" in both, three seconds after the same backspace.

The empty-field path above strands the same way on main; the line fixes both.

hasCreate builds the Create entry inside the search, so the threshold gates
creating too — QA + Enter adds a tag today and nothing with
minQueryLength={3}. Should Create sit outside the gate?

Also needs a merge with main (#5400
moved the keydown switch).

Can you add that line and re-push?

[Reviewed by Robohands]

… doc entry

Addresses the review on #5385.

**The stranded loading state.** Falling below `minQueryLength` bumps the search
generation to abandon the in-flight search — and that is exactly what makes the
abandoned search's own `finally` decline to clear `isLoading`, since it guards
on `searchGenRef.current === gen`. The field then reported "Loading" to
assistive technology until another search settled. Backspacing from three
characters to two on a remote source is the everyday way to reach it.

The same branch also covers the empty-field path, which strands identically and
does so on main today.

`handleSelect` abandons a search the same way and had the same hole: the menu
can still be showing the previous query's results while the next search is in
flight, so choosing one bumps the generation with a search still out. One line
there too.

**The zh doc entry.** `Tokenizer.doc.mjs`'s `docsZh` carried the English
description for `minQueryLength`; BaseTypeahead's was already translated. Now
matches it. (The short-blurb map lower in the same `docsZh` stays English —
that is how every prop in it reads, `menuWidth` included.)

**The merge.** #5400 added `menuWidth` beside this branch's `minQueryLength` in
the same four files, so every conflict was two props landing at one spot: both
kept, main's first. Two of them cut through an object literal in the doc props
array and had to be split back into separate entries rather than concatenated,
or the merged object would carry two `name:` keys and silently document only
one prop.

Verified in Chromium against a built Storybook, a 1.2s remote source and
`minQueryLength={3}`, reading the `role="status"` element's accessible name
three seconds after the backspace:

    before   whileSearching: "Loading"   afterBackspace: "Loading"
    after    whileSearching: "Loading"   afterBackspace: null

The regression test covers the below-threshold path. The select path is not
unit-tested: this suite's popover mock never puts options in the accessibility
tree, so there is no way to select one from jsdom.

@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 fixing the stranded loading state — I re-ran the 600ms remote search, backspaced 3→2, and loading now clears immediately and stays clear after settlement.

One API interaction remains: with hasCreate, QA + Enter creates a token by default, but minQueryLength={3} makes Enter do nothing. minQueryLength is a search threshold, so it should not suppress the separate create capability.

Current main also fixes this head’s visual-gate failure; the merge added unrelated DateInput formatting. Could you keep creation available below the threshold, add that Tokenizer combination test, refresh main, and drop the DateInput noise?

[Reviewed by Robohands]

Addresses the review on #5385.

**`hasCreate` is no longer gated by the threshold.** You're right that these
are separate capabilities: `minQueryLength` exists to avoid a *fetch* too broad
to be worth making, and creating costs no fetch. `QA` + Enter adding a tag
should not stop working because a search for `QA` would match too much.

The reason it was gated is that the "Create X" entry rode on the search
results — Tokenizer appended it inside its wrapped `search`, so no search meant
no entry. It is derived from the typed text rather than fetched for it, so it
now travels a separate path: `BaseTypeahead` takes `queryEntries(query,
results)`, appends whatever it returns to the menu, and offers it whatever the
threshold says. Tokenizer supplies the Create entry through it.

Two details that fall out of the split:

- `hasSearched` stays false on the below-threshold path, so a query that was
  never searched still cannot report "no results" — the case the original gate
  comment was protecting.
- `queryEntries` receives the results it will be appended to, so the existing
  duplicate check still sees them and Create is withheld for an exact match.

Three tests cover the combination: Create offered below the threshold with the
source never called and the token committing; the negative control with
`hasCreate` off, where the menu stays shut and says nothing; and a
below-threshold query matching a token already held, where Create is withheld.

**Merged main** — which also brings in the visual-gate fix — and restored
`packages/core/src/DateInput/` and `.changeset/date-input-native-picker-option.md`
to main. That was prettier reformatting, applied by the pre-commit hook to
files the previous merge happened to stage; nothing in this PR needed it. The
diff is now ten files, all Typeahead/Tokenizer.

@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 — the create fix is right, and derived-not-fetched is the right shape. Drove it at 600ms: QA offers Create "QA", Enter commits, the source is never called, and the 3→2 backspace still clears loading.

before after
before after

"QA" in both, with hasCreate and minQueryLength={3}.

One thing before it lands. queryEntries sits on BaseTypeaheadProps, which the core barrel re-exports, so it ships as public API at the next cut with Tokenizer as its only caller and no BaseTypeahead.doc.mjs entry. Keep the mechanism, keep it off the contract — DefinedTheme.__inputTokens (defineTheme.ts:395) is how we carry a prop that has to live on an exported type.

Worth a body line too: with hasCreate and no threshold, the Create entry now survives the maxMenuItems cut — 11 options where main showed 10.

Can you re-push with that?

[Reviewed by Robohands]

…tract

`BaseTypeaheadProps` is re-exported from the package entry point, so
`queryEntries` would have shipped as public API at the next cut with
Tokenizer as its only caller and no doc entry — cixzhang's hold.

Renamed to `__queryEntries` and marked `@internal`, following
`DefinedTheme.__inputTokens`. The mechanism is unchanged; only its
standing is. Tokenizer is still the only caller.

Also, on the same review:

- The Tokenizer docs said the menu "stays closed" below the threshold,
  which stopped being true when Create was let through. All three
  entries — English, Chinese, dense — now say Create is the exception.
- `maxMenuItems` is documented as bounding *results*: the Create entry
  is appended after the cut, so a full menu shows one more than the cap
  (11 where main showed 10). A new test pins that, since it is the kind
  of thing a later refactor would "tidy" back into the slice.
- The changeset carries both.
@github-actions
github-actions Bot requested a review from cixzhang August 27, 2026 01:09
@freddymeta

Copy link
Copy Markdown
Contributor Author

Both asks in, pushed as 5067e1039.

queryEntries off the contract. Renamed __queryEntries and marked @internal, following DefinedTheme.__inputTokens — the mechanism is untouched, only its standing. Tokenizer remains the only caller, and nothing else in the repo referenced it.

The maxMenuItems line is in the body, and it turned out to be worth more than a line. Chasing it, the Tokenizer docs were saying something that had quietly stopped being true:

Minimum query length before the search source is queried. Below it no search runs and the menu stays closed.

The menu does not stay closed below the threshold once hasCreate is set — that is the whole point of the carve-out. All three Tokenizer entries (English, Chinese, dense) now name the exception, and maxMenuItems says it bounds results, with the Create entry sitting on top of them.

I also pinned the 11-vs-10 behaviour with a test rather than leaving it to the body:

it('offers Create on top of a full menu, not in place of a result', ...)
  maxMenuItems={3}, 20 matching results, hasCreate
  → 4 options, the last one Create "QA"

Left as an assertion because it is precisely the shape a later refactor would "tidy" by moving the append inside the slice — which would silently drop a result to make room for Create, or drop Create when results are plentiful. Neither is what we want, and neither would fail anything today.

(The inline docsZh note was fixed back in 57cde40f8; replied on the thread.)

@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 — both asks are in: __queryEntries is internal, and the maxMenuItems exception is documented and tested. Typeahead/Tokenizer suites and both Chromium paths pass at this head.

[Reviewed by Robohands]

@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Aug 27, 2026
@freddymeta
freddymeta merged commit 70dea86 into main Aug 27, 2026
26 checks passed
@github-actions
github-actions Bot deleted the feat/typeahead-min-query-length branch August 27, 2026 09:11
Geervan pushed a commit to Geervan/astryx that referenced this pull request Sep 2, 2026
…#5682)

* fix(Typeahead,Tokenizer): the busy indicator is a Spinner in the field's end lane, and the input reserves it

Three defects in one block. The indicator a search painted was
`<Icon icon="clock">` — a static glyph, byte-identical to TimeInput's, in a
family where every other input paints busy with a Spinner and where `clock`
otherwise means *time*. It was an in-flow item at the row's inline end, which
is where each field independently parks its clear button, so the two landed on
each other: 17x20px of overlap in Typeahead, 19x20px in Tokenizer, the latter
leaving part of the clear glyph unclickable. And the combobox never carried
`aria-busy`.

The engine reports the busy state instead of painting it, and each field
paints it in the one inline-end lane it already owns beside its clear button
and end content. A direct `BaseTypeahead` caller keeps the visible, named
status it has always had — as a Spinner now, so the fix reaches those callers
too — and passing the callback is what hands the indicator over, so a field
never renders two.

The lane is out of flow (these wrappers wrap, and an in-flow sibling gets
pushed onto a second row by a token), so it reserved nothing and the query ran
underneath it at a narrow width. `useEndLaneReserve` measures the rendered
lane and returns the padding the input needs. Measured rather than assumed,
because what the lane holds varies with the field's state and, in Tokenizer,
includes arbitrary `endContent`.

At 280px, all six states measured, overlap of the input's content box with
the lane's controls:

| | main | here |
|---|---|---|
| Typeahead, value settled | clear 17px | 0 |
| Typeahead, value + search in flight | 0 | 0 |
| Tokenizer, value idle / settled | clear 25px | 0 |
| Tokenizer, value + search in flight | 0 | 0 |

The two rows that were already 0 were only 0 because the in-flow indicator
reserved its own width; moving it out is what would have regressed them, and
the reserve is what holds them. The other two are the pre-existing case of the
same bug, with no spinner in it at all.

Reporting goes out at the call site through a ref rather than from an Effect,
so the field's state change batches into the commit React was already doing
instead of forcing a second one, and it is edge-triggered, so the redundant
clear on every keystroke below the query threshold reports nothing.

Stacked on meta#5385 until it landed; replanted on main now that it has.

* refactor(Typeahead): sync the report callback in a layout effect, not during render

Two audit findings, neither user-visible.

The latest-callback ref was assigned during render. The repo's own convention
splits on exactly this: plain values are assigned during render
(`snapPointsRef` in BottomSheetPanel), but the latest-callback refs beside
them — `onMotionStartRef`, `onMotionCompleteRef` — are synced in a layout
effect, because a render React discards must not leave the ref pointing at a
callback from the abandoned pass. This effect writes a ref and nothing else,
so it commits nothing and no wrapper re-renders for it; the doubled commits
the review asked about stay gone.

And the ResizeObserver's fallback for a browser with no `borderBoxSize` read
`contentRect`, which is the content box — equal today, since the lane has no
padding or border, and silently short the moment one is added. `offsetWidth`
on the observed element is border-box, like the primary path.

* perf(Typeahead,Tokenizer): keep the lane measurement out of React state

The reserve fixed the overlap and paid for it in commits: a 20-token
search went from 20 renders to 120, and the reserve alone accounted for
the second half. `useEndLaneReserve` held the measured width in state,
so the lane changing size — which it does exactly twice a search, as the
spinner arrives and as it leaves — re-rendered the whole field to carry
a number no JavaScript ever reads.

It reaches CSS as a custom property written straight to the field
wrapper and inherited by the input, so the padding follows the lane
without React seeing the value at all. The rule is static now: one
class, `calc(inset + var(--_astryx-end-lane-width, 0px))`, generated
once instead of regenerated per width.

Measured, same test either way — `Profiler` around the field, one search
start to settle:

    state-held reserve   2 commits at search start   (fails)
    custom property      1 commit                    (passes)

which is the doubling, and it holds for the settle edge too. jsdom
reports every width as 0, so a state-held reserve never re-renders
there and the regression is invisible; the test stubs a ResizeObserver
that reports a width, which is the smallest thing that makes it
reproducible in CI.

The observer is shared as well — `observeResize`, the same singleton
`useTruncation` uses. Three fields on a page created three observers
before and create one now, so the browser dispatches one callback a
frame rather than N.

Verified in Chromium at 280px that the accepted fix still holds: while
busy, the input's content box ends at 268 and the lane starts at 276 —
zero overlap with the caret, and the reserve is released when the lane
goes.

* fix(Typeahead,Tokenizer): put Typeahead's end controls in flow, and measure Tokenizer's lane in local space

Two things, both from the transform report.

**The measured width was in the wrong coordinate space.**
`getBoundingClientRect()` reports viewport space — it carries every CSS
transform above the element — while the padding it fed is in the element's
own local space. Reproduced in Chromium on a 98px lane: `scale(.5)` published
49px, reserved half of what was needed, and put the live query back under the
controls by 22.83px; `scale(2)` published 196px and left the caret in a
202.69px gap. `offsetWidth` is the untransformed border-box width and reads 98
at every scale, so that is what the reserve now uses. It is already an
integer, which is the rounding the old `Math.ceil` was there for.

**Typeahead does not need a measured lane at all.**
Its spinner and clear button are now ordinary in-flow flex siblings of the
input, which is TextInput's shape for exactly these controls: an in-flow box
takes up room, so nothing can run underneath it and there is nothing to
measure. The whole reserve, and the absolute lane it existed for, are gone
from this field.

What stood in the way was `flex-wrap: wrap` on Typeahead's wrapper — not a
decision about this field, but something it picked up wholesale in the meta#2941
rename migration. The shared field base does not set it and TextInput does not
use it. It cannot coexist with in-flow end controls either, because flex moves
an item to a new line rather than shrinking it: with it, a long value put the
clear button and spinner on a row of their own and a 280px field grew to 46px
tall. Removed, the token ellipsizes instead — which is what Token already
does, capping itself at 100% and clipping — and the field stays one row.

Two rules I tried on the way out did nothing and are not here: `min-width: 0`
on the token and `flex-shrink: 0` on the lane both measured byte-identical
with and without, because Token already shrinks and the controls' min-content
is their own size.

Tokenizer keeps the lane. It cannot use the in-flow shape: its lane stays
pinned to the field's first row while tokens wrap below it, so it has to be
out of flow.

Chromium, busy, at scale .5 / 1 / 2 — Typeahead: no reserve at all, overlap 0,
0, 0. Tokenizer: 98px published at all three, overlap 0, 0, 0, and a constant
3.34px local gap. Before, the same three read 22.83px of overlap, 0, and
202.69px of gap.

Coverage, per the review: Tokenizer gains the busy-only path (a spinner as the
lane's only occupant) and the collapsed path (the input takes no reserve when
it has no width to pad), plus a direct regression test for the bug — the stub
reports 24px from `offsetWidth` and 12px from the rect, and the published
value must be 24px. Typeahead gains three guards that its controls stay in
flow: no absolute lane, no reserve property, no wrapping. Reverting either fix
fails its test.

* fix(Typeahead): hold the end controls in the corner, and file the reserve with its one caller

Self-review of the previous commit found one bug and one misfiling.

**The clear button drifted into the middle of the field.** Putting the
controls in flow is right, but TextInput gets them to the inline end for free:
its input is always present and `flex: 1`, so it absorbs the free space and
pushes them over. Typeahead collapses its input to nothing whenever a token
shows — which is the ordinary state of a field with a value — leaving no
flexible item in the row, so the controls came to rest against the token.
Measured: the clear button at x=39 in a 300px field, where TextInput's sits at
281. An `auto` margin gives the free space to the margin instead of to a
sibling, so it needs no sibling to exist: 281 now, and 0px of drift when the
spinner joins it, matching TextInput exactly.

That is also why these two are wrapped again. The wrapper is an ordinary
in-flow flex child, not the absolute lane the review objected to — it is
simply the one element the margin can sit on when either control may be
absent.

**`useEndLaneReserve` moved from `Field/` to `Tokenizer/`.** It has exactly
one caller now. Everything else in `Field/` is genuinely shared —
`InputClearButton` has 15 consumers — so a Tokenizer-only workaround filed
there read as shared infrastructure and invited the next field to reach for
the measured reserve, which is the thing this review was about not doing.

Also checked and left alone: no dead style keys in any of the three files, no
unused imports, the hook is not re-exported from any barrel, and
`--typeahead-min-width` is not involved. Two candidate rules from the last
round measured byte-identical with and without and are still absent.

Chromium, busy, scale .5 / 1 / 2 — Typeahead: no reserve, overlap 0 / 0 / 0,
controls pinned to the field's end at a constant inset, one row throughout.
Tokenizer: 98px published at all three, overlap 0 / 0 / 0.

One note for a separate change: the `@astryx.typeahead.loading` catalog entry
describes a spinner "inside a Typeahead dropdown". It has always rendered in
the field row, not the dropdown, so the description was already wrong on main;
left for its own diff rather than widening this one.

* docs(Typeahead,Tokenizer): file the busy indicator as anatomy that delegates to Spinner

The indicator is a shared primitive, so `architecture:component-theming-surface`
INV5 says it delegates rather than earning a target — but the part has to be in
the inventory for that disposition to exist. Adds the `Spinner` anatomy row to
both component docs and maps it in Typeahead's `anatomy-theming:v1` block as
`delegatesTo component:Spinner/spinner`, which is what TextArea, CheckboxList
and CommandPalette already declare for the same part. No target, no var, no DOM
change.

Also renames the lane's private custom property `--_astryx-end-lane-width` ->
`--_tokenizer-end-lane-width`. It was the only `--_astryx-*` name in the repo;
every other private var names its owning component, and a system-shaped name on
a component-owned measurement invites exactly the cross-layer reliance INV11
rules out.

Corrects two claims that do not survive re-measurement against a build of
current main, and refreshes the measured numbers in the comments to today's:
the clear button stays clickable under the indicator (it is positioned, so it
paints above), and the pre-existing clear-over-content overlap is Tokenizer's
20px, not Typeahead's.

* fix(Typeahead,Tokenizer): close the busy handoff behind a module boundary

`__onLoadingChange` sat on `BaseTypeaheadProps`, which the package entry
point re-exports — so a builder reading the exported declaration finds it
and can reasonably wire it, pinning a wiring detail between two wrappers
and their base as permanent public API. The `@internal` tag is a note to
a reader, not a boundary.

The handoff now travels through a context in `busyIndicatorLane.tsx`,
which `index.ts` does not export: the wrapper provides its setter around
the base, the base subscribes. The seam is closed by module boundary
rather than by naming convention, and there is nothing left on the public
prop surface to find.

Behaviour is unchanged. A lane present still means the wrapper paints the
indicator in the end lane it already owns and the base renders none; no
lane still means the base renders its own visible, named status — the
released behaviour when the base is used directly.

A test asserts the seam: the entry point exports neither the provider nor
the hook, and BaseTypeahead.tsx no longer contains the prop. It fails
against the previous commit.

8605 core tests, check:repo green.

* fix(Typeahead): bound the selected value with a content lane

Squashed to one commit and rebased onto the current meta#5555 head.

A selected token used to be positioned over a collapsed input, so the
field's width came from whatever was left rather than from its content.
The value now sits in a content lane that owns the flexible space, and
the end controls hold the corner with an `auto` margin, so the field
keeps its width when a value is chosen.

Also closes Typeahead's RTL coverage gap. Every dimension returned N/A,
which the audit counts as unmeasured rather than RTL-ready — and the
content lane is exactly the direction-sensitive part: the token opens the
lane, the clear button closes it, and RTL must swap them. A single-field
`Logical order` story plus a curated D2 target measures that flip; the
existing comparison story renders two fields, and the selectors would
match across both.

  pnpm rtl:audit -- --filter Typeahead
  CUR  RTL-ready  core/typeahead  {"D2":"pass"}
  COV : 1 measured / 0 verified N-A / 0 gap / 0 stale

The probe was verified rather than assumed: pinning the field to
`direction: ltr` turns D2 pass -> partial, so the check reads real
geometry. It passes against main's Typeahead too — the order flip is
writing-mode driven either way — so this closes a coverage gap rather
than guarding the content lane specifically.

The busy handoff this branch used to carry is now meta#5555's own; nothing
here passes it.

---------

Co-authored-by: freddymeta <[email protected]>
Co-authored-by: freddytan <[email protected]>
Co-authored-by: freddymeta <[email protected]>
Co-authored-by: freddytan <[email protected]>

This branch was successfully deployed

1 active deployment
Preview — 5067e103 Deployed Aug 27, 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. community Authored by a community contributor (not on the eng/design team)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFC] Typeahead/Tokenizer: no way to hold the search until the query is long enough

2 participants