An open source design system that's fully customizable and agent ready
TypeScript
feat(core): search fields ask a touch keyboard for its Search key and no autocorrection (#8157)
Christopher Chedeaud0b6e0f77eee
diff --git a/.changeset/search-fields-search-key.md b/.changeset/search-fields-search-key.mdnew file mode 100644index 0000000000..e966e9810c--- /dev/null+++ b/.changeset/search-fields-search-key.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[feat] Search fields ask a touch keyboard for its Search key and no autocorrection. The search inputs of Typeahead, Tokenizer (and so PowerSearch), CommandPaletteInput and the Selector and MultiSelector search row now carry `enterkeyhint="search"` and `autocorrect="off"`. A phone keyboard then shows a Search key instead of Return and leaves names and identifiers as typed. The key is only a label: Enter does what it did before in each field.++@vjeuxdiff --git a/docs/families/input-fields.md b/docs/families/input-fields.mdindex f29edffa15..59d6b73901 100644--- a/docs/families/input-fields.md+++ b/docs/families/input-fields.md@@ -18,6 +18,9 @@ verified_by:packages/core/src/Selector/Selector.test.tsx,packages/core/src/Typeahead/Typeahead.test.tsx,packages/core/src/Tokenizer/Tokenizer.test.tsx,+ packages/core/src/Typeahead/BaseTypeahead.test.tsx,+ packages/core/src/MultiSelector/MultiSelector.test.tsx,+ packages/core/src/Field/__tests__/SearchKeyboard.interaction.browser.spec.ts,packages/core/src/inputFontFloor.test.ts,]members:@@ -385,9 +388,6 @@ DEC-6 does not require unrelated components to add a new floor.styling passed through a product wrapper's own props or spread; FR10's typeerror surfaces those callsites.-- **Search keyboard (FR12):** the search inputs of Typeahead, Tokenizer, and- the Selector and MultiSelector search row set neither `enterkeyhint` nor- `autocorrect`, so a touch keyboard shows Return and corrects queries.- **Verification coverage:** current unit tests prove composition, semantics, andindividual state behavior, but do not yet provide the complete real-browserinline-size/end-overlap matrix below. This current record names those@@ -398,20 +398,20 @@ The exhaustive coverage obligation follows the membership and adoption tables.## Verification map-| Contract | Verification | Representative members and states | Mutation or failure expectation |-| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |-| FR1 | Real-Chromium before/after inline-size measurements in block, flex-item, inline-block, grid auto-track, and explicit-width containers | TextInput baseline; Selector exception; Typeahead empty/selected/source-busy; Tokenizer zero/one/many tokens | Value or busy state changes the field's outer inline size outside a recorded exception |-| FR2 | Real-Chromium content-box/control-box overlap matrix at narrow supported widths and LTR/RTL | clear, Spinner, status, disclosure, Tokenizer `endContent`; alone and combined | Content, caret, or pointer hit area intersects a rendered end control, or stale reserve remains after it unmounts |-| FR3 | InputGroup unit tests plus rendered size/height, surface/focus-ownership, overflow, and interaction checks | every admitted member; Tokenizer zero/one/many tokens, focused/unfocused, explicit/default overflow; mismatched child/group sizes | A child keeps competing outer geometry, expands or adds a row, loses connected focus/border ownership, or changes naming, keyboard, focus, editing, or selection semantics |-| FR4 | Keyboard, pointer, and accessibility-tree tests | each member that exposes `disabledMessage` | Reason becomes unreachable, or the disabled control mutates/activates |-| FR5 | Selector and MultiSelector interaction and announcement tests from AST-001 | populated options while input-busy; explicit source-pending; completed empty | Input busy suppresses supplied options or substitutes for source state |-| FR6 | Focused callback/order/optimistic/busy tests for every Action-capable mutation path | typing, selection, calendar/preset, file selection, and clear where exposed | Callback/Action order changes, optimistic feedback disappears, or a clear path bypasses the Action contract |-| FR7 | Typeahead/Tokenizer source-busy tests and real-browser geometry checks | direct BaseTypeahead, standalone wrappers, grouped Typeahead, selected/tokenized values | Busy feedback is unnamed/duplicated, `aria-busy` is absent, or source loading changes row/inline geometry |-| FR8 | Representative member tests plus real-browser overlap/opacity/height checks | eligible single-line direct controls; wrapped, custom, tall, and translucent controls; all three placements | Attached is missing where supported, appears where unsafe, or tooltip reaches direct FieldStatus |-| FR9 | `inputFontFloor.test.ts`, focused computed-style checks, and real iOS Safari focus evidence | iOS touch, non-iOS coarse pointer, and desktop fine pointer | iOS renders below 16 CSS px or focus zooms, or a non-iOS coarse pointer receives the iOS-only floor |-| FR10 | A type test over every Field-composed component's props that fails if one accepts root `xstyle`, `className`, or `style`; per-component render tests for every base prop, `container*`, and `control*` prop and for both development warnings | every Field-composed component standalone, in horizontal-label FormLayout, and inside InputGroup where admitted | A component type-checks with root styling, a base prop lands off the primary semantic control, `container*` lands off the Field box or on the control box, `control*` lands off the control box, or a warning is missing |-| FR11 | `InputClearButton.test.tsx` tooltip and accessible-name assertions, plus real-Chromium hover captures | a long field label; a locale override; light and dark | The tooltip repeats the field label, or the accessible name loses the field label |-| FR12 | Evidence gap until built: render tests on each listed member's search input for `enterkeyhint="search"` and `autocorrect="off"`, with Enter keeping its member-owned effect; a real-browser touch-emulation check that the focused search input carries both | Typeahead; Tokenizer; Selector and MultiSelector search row; a phone viewport with touch emulation | A missing attribute, or an Enter whose effect changes with the label, fails |+| Contract | Verification | Representative members and states | Mutation or failure expectation |+| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |+| FR1 | Real-Chromium before/after inline-size measurements in block, flex-item, inline-block, grid auto-track, and explicit-width containers | TextInput baseline; Selector exception; Typeahead empty/selected/source-busy; Tokenizer zero/one/many tokens | Value or busy state changes the field's outer inline size outside a recorded exception |+| FR2 | Real-Chromium content-box/control-box overlap matrix at narrow supported widths and LTR/RTL | clear, Spinner, status, disclosure, Tokenizer `endContent`; alone and combined | Content, caret, or pointer hit area intersects a rendered end control, or stale reserve remains after it unmounts |+| FR3 | InputGroup unit tests plus rendered size/height, surface/focus-ownership, overflow, and interaction checks | every admitted member; Tokenizer zero/one/many tokens, focused/unfocused, explicit/default overflow; mismatched child/group sizes | A child keeps competing outer geometry, expands or adds a row, loses connected focus/border ownership, or changes naming, keyboard, focus, editing, or selection semantics |+| FR4 | Keyboard, pointer, and accessibility-tree tests | each member that exposes `disabledMessage` | Reason becomes unreachable, or the disabled control mutates/activates |+| FR5 | Selector and MultiSelector interaction and announcement tests from AST-001 | populated options while input-busy; explicit source-pending; completed empty | Input busy suppresses supplied options or substitutes for source state |+| FR6 | Focused callback/order/optimistic/busy tests for every Action-capable mutation path | typing, selection, calendar/preset, file selection, and clear where exposed | Callback/Action order changes, optimistic feedback disappears, or a clear path bypasses the Action contract |+| FR7 | Typeahead/Tokenizer source-busy tests and real-browser geometry checks | direct BaseTypeahead, standalone wrappers, grouped Typeahead, selected/tokenized values | Busy feedback is unnamed/duplicated, `aria-busy` is absent, or source loading changes row/inline geometry |+| FR8 | Representative member tests plus real-browser overlap/opacity/height checks | eligible single-line direct controls; wrapped, custom, tall, and translucent controls; all three placements | Attached is missing where supported, appears where unsafe, or tooltip reaches direct FieldStatus |+| FR9 | `inputFontFloor.test.ts`, focused computed-style checks, and real iOS Safari focus evidence | iOS touch, non-iOS coarse pointer, and desktop fine pointer | iOS renders below 16 CSS px or focus zooms, or a non-iOS coarse pointer receives the iOS-only floor |+| FR10 | A type test over every Field-composed component's props that fails if one accepts root `xstyle`, `className`, or `style`; per-component render tests for every base prop, `container*`, and `control*` prop and for both development warnings | every Field-composed component standalone, in horizontal-label FormLayout, and inside InputGroup where admitted | A component type-checks with root styling, a base prop lands off the primary semantic control, `container*` lands off the Field box or on the control box, `control*` lands off the control box, or a warning is missing |+| FR11 | `InputClearButton.test.tsx` tooltip and accessible-name assertions, plus real-Chromium hover captures | a long field label; a locale override; light and dark | The tooltip repeats the field label, or the accessible name loses the field label |+| FR12 | `Typeahead.test.tsx`, `BaseTypeahead.test.tsx`, `Tokenizer.test.tsx`, `Selector.test.tsx`, and `MultiSelector.test.tsx` cases for both attributes, with Enter keeping its member-owned effect; `SearchKeyboard.interaction.browser.spec.ts` on a touch-emulated phone, where the search input a tap focuses carries both | Typeahead; Tokenizer; Selector and MultiSelector search row; a phone viewport with touch emulation | A missing attribute, or an Enter whose effect changes with the label, fails |## Decision linksdiff --git a/docs/specs/components/CommandPalette/CommandPaletteInput.spec.md b/docs/specs/components/CommandPalette/CommandPaletteInput.spec.mdindex 5a3e0246f4..2f6ff1a123 100644--- a/docs/specs/components/CommandPalette/CommandPaletteInput.spec.md+++ b/docs/specs/components/CommandPalette/CommandPaletteInput.spec.md@@ -13,6 +13,7 @@ review_triggers: [public-api, behavior, layout, theming, accessibility]verified_by:[packages/core/src/CommandPalette/CommandPaletteInput.test.tsx,+ packages/core/src/Field/__tests__/SearchKeyboard.interaction.browser.spec.ts,apps/storybook/stories/CommandPaletteInput.stories.tsx,apps/storybook/rtl-audit/targets.json,packages/core/src/theme/themingTargets.test.ts,@@ -99,14 +100,14 @@ Consumer migration instructions belong in consumer docs and release notes.## Behavioral and layout contract-| ID | Candidate invariant | Basis | Draft review state |-| --- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------ | ---------------------------------------------------------- |-| FR1 | Explicit `value` and `onValueChange` take precedence; otherwise CommandPalette context supplies search state; native uncontrolled state remains when neither exists. | Released source, docs, and tests | Verified current behavior |-| FR2 | Consumer `onKeyDown` runs before contextual navigation; preventing the event, or an active IME composition, prevents contextual delegation. | Released source and tests | Verified current behavior |-| FR3 | `ref` and native passthrough attributes reach the native query field; standalone caller-owned popup semantics persist, while CommandPalette context owns its popup role and relationships; `xstyle`, `className`, and `style` customize the surrounding Input. | Released source and docs; `architecture:public-component-api/INV5` | Verified current routing |-| FR4 | Pending state and renderable `endContent` share one trailing-content group; booleans, empty strings, null, and undefined do not create empty trailing chrome. | React rendering semantics and current utility contract | Verified current behavior |-| FR5 | Auto-focus is enabled by default and suppressed inside an inline Dialog; `hasAutoFocus={false}` suppresses both focus work and the autofocus marker. | Released source, docs, and tests | Verified current behavior; browser timing evidence remains |-| FR6 | The query field carries `enterkeyhint="search"` and `autocorrect="off"`, standalone and inside CommandPalette, as `family:input-fields` FR12 states for search inputs; Enter keeps FR2's routing whatever the key shows. Implementation gap: the field sets neither attribute. | `family:input-fields/FR12, DEC-10` | Implementation gap |+| ID | Candidate invariant | Basis | Draft review state |+| --- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ | ---------------------------------------------------------- |+| FR1 | Explicit `value` and `onValueChange` take precedence; otherwise CommandPalette context supplies search state; native uncontrolled state remains when neither exists. | Released source, docs, and tests | Verified current behavior |+| FR2 | Consumer `onKeyDown` runs before contextual navigation; preventing the event, or an active IME composition, prevents contextual delegation. | Released source and tests | Verified current behavior |+| FR3 | `ref` and native passthrough attributes reach the native query field; standalone caller-owned popup semantics persist, while CommandPalette context owns its popup role and relationships; `xstyle`, `className`, and `style` customize the surrounding Input. | Released source and docs; `architecture:public-component-api/INV5` | Verified current routing |+| FR4 | Pending state and renderable `endContent` share one trailing-content group; booleans, empty strings, null, and undefined do not create empty trailing chrome. | React rendering semantics and current utility contract | Verified current behavior |+| FR5 | Auto-focus is enabled by default and suppressed inside an inline Dialog; `hasAutoFocus={false}` suppresses both focus work and the autofocus marker. | Released source, docs, and tests | Verified current behavior; browser timing evidence remains |+| FR6 | The query field carries `enterkeyhint="search"` and `autocorrect="off"`, standalone and inside CommandPalette, as `family:input-fields` FR12 states for search inputs; Enter keeps FR2's routing whatever the key shows. | `family:input-fields/FR12, DEC-10` | Verified current behavior |### Allowed variation@@ -184,14 +185,14 @@ Consumer migration instructions belong in consumer docs and release notes.## Verification map-| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |-| ----------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ |-| FR1–FR3 | `CommandPaletteInput.test.tsx` | explicit, context, prevented key, native, caller popup | Reversing state precedence, rerouting the ref, dropping standalone popup relationships, or allowing context semantics to be clobbered fails focused DOM tests. | `audit:CommandPaletteInput/testing` |-| FR4 | `CommandPaletteInput.test.tsx` | numeric, empty, busy, caller content | Truthiness routing creates empty chrome or moves numeric content away from the trailing edge. | `audit:CommandPaletteInput/behavior` |-| FR5 | focused unit tests plus exact-head browser evidence | enabled, disabled, inline | Eligible focus is lost, disabled focus is scheduled, or inline mode steals focus. | `audit:CommandPaletteInput/behavior` |-| FR6 | Evidence gap until built: `CommandPaletteInput.test.tsx` attribute cases standalone and in context, and a real-browser touch-emulation check | standalone; contextual; a phone viewport with touch emulation | A missing `enterkeyhint` or `autocorrect`, or changed Enter routing, fails. | `audit:CommandPaletteInput/behavior` |-| AR1–AR3 | unit tests, exact-head axe/browser run, and source review | standalone, open, closed, highlighted | Wrong role/state, consumer clobbering of an owned attribute, or a placeholder-derived name fails semantics and name assertions. | `audit:CommandPaletteInput/a11y` |-| Theming/RTL | target inventory, Storybook fixture, and RTL D2 audit | standalone trailing content, contextual | Target loss or physical ordering fails the owned fixture. | `audit:CommandPaletteInput/theming` |+| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |+| ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ |+| FR1–FR3 | `CommandPaletteInput.test.tsx` | explicit, context, prevented key, native, caller popup | Reversing state precedence, rerouting the ref, dropping standalone popup relationships, or allowing context semantics to be clobbered fails focused DOM tests. | `audit:CommandPaletteInput/testing` |+| FR4 | `CommandPaletteInput.test.tsx` | numeric, empty, busy, caller content | Truthiness routing creates empty chrome or moves numeric content away from the trailing edge. | `audit:CommandPaletteInput/behavior` |+| FR5 | focused unit tests plus exact-head browser evidence | enabled, disabled, inline | Eligible focus is lost, disabled focus is scheduled, or inline mode steals focus. | `audit:CommandPaletteInput/behavior` |+| FR6 | `CommandPaletteInput.test.tsx` attribute and Enter cases, standalone and in context; `SearchKeyboard.interaction.browser.spec.ts` on a touch-emulated phone | standalone; contextual; a phone viewport with touch emulation | A missing `enterkeyhint` or `autocorrect`, or changed Enter routing, fails. | `audit:CommandPaletteInput/behavior` |+| AR1–AR3 | unit tests, exact-head axe/browser run, and source review | standalone, open, closed, highlighted | Wrong role/state, consumer clobbering of an owned attribute, or a placeholder-derived name fails semantics and name assertions. | `audit:CommandPaletteInput/a11y` |+| Theming/RTL | target inventory, Storybook fixture, and RTL D2 audit | standalone trailing content, contextual | Target loss or physical ordering fails the owned fixture. | `audit:CommandPaletteInput/theming` |## Decision logdiff --git a/packages/core/src/CommandPalette/CommandPaletteInput.test.tsx b/packages/core/src/CommandPalette/CommandPaletteInput.test.tsxindex 21dc2613c7..a92e1435c5 100644--- a/packages/core/src/CommandPalette/CommandPaletteInput.test.tsx+++ b/packages/core/src/CommandPalette/CommandPaletteInput.test.tsx@@ -78,6 +78,32 @@ describe('CommandPaletteInput', () => {expect(input).not.toHaveAttribute('aria-autocomplete');});+ it('asks a touch keyboard for its Search key and no autocorrection, standalone and in a palette', () => {+ const {unmount} = render(<CommandPaletteInput />);+ expect(screen.getByRole('searchbox')).toHaveAttribute(+ 'enterkeyhint',+ 'search',+ );+ expect(screen.getByRole('searchbox')).toHaveAttribute('autocorrect', 'off');+ unmount();++ const onKeyDown = vi.fn();+ render(+ <CommandPaletteContext value={makeContext({onKeyDown})}>+ <CommandPaletteInput />+ </CommandPaletteContext>,+ );+ const input = screen.getByRole('combobox');+ expect(input).toHaveAttribute('enterkeyhint', 'search');+ expect(input).toHaveAttribute('autocorrect', 'off');++ // Enter keeps its routing to the palette whatever the key shows.+ fireEvent.keyDown(input, {key: 'Enter'});+ expect(onKeyDown).toHaveBeenCalledWith(+ expect.objectContaining({key: 'Enter'}),+ );+ });+it('preserves standalone caller-owned popup semantics', () => {render(<CommandPaletteInputdiff --git a/packages/core/src/CommandPalette/CommandPaletteInput.tsx b/packages/core/src/CommandPalette/CommandPaletteInput.tsxindex 080a354fab..8cf14dfc6d 100644--- a/packages/core/src/CommandPalette/CommandPaletteInput.tsx+++ b/packages/core/src/CommandPalette/CommandPaletteInput.tsx@@ -46,6 +46,7 @@ import {useComponentTranslator,} from '../i18n/useComponentTranslator';import english from '../i18n/generated-english/CommandPalette/CommandPaletteInput.generated';+import {textEntryTraitAttributes} from '../Field/textEntryTraits';registerEnglishFallback(english);const styles = stylex.create({@@ -320,6 +321,11 @@ export function CommandPaletteInput({? focusOutlineProps.focusVisible(styles.input): focusOutlineProps.suppressed(styles.input))}type="text"+ // Autocorrect would rewrite names and identifiers.+ {...textEntryTraitAttributes({+ enterKeyHint: 'search',+ hasAutoCorrect: false,+ })}role={ctx ? 'combobox' : standaloneRole}aria-expanded={ctxdiff --git a/packages/core/src/Field/PanelSearchInput.tsx b/packages/core/src/Field/PanelSearchInput.tsxindex cb557dc001..521a62b428 100644--- a/packages/core/src/Field/PanelSearchInput.tsx+++ b/packages/core/src/Field/PanelSearchInput.tsx@@ -57,6 +57,7 @@ import {typographyVars,} from '../theme/tokens.stylex';import type {BaseProps} from '../BaseProps';+import {textEntryTraitAttributes} from './textEntryTraits';const styles = stylex.create({// Gutter only. Matches the option list's own padding so the field below@@ -273,6 +274,11 @@ export function PanelSearchInput({<inputref={mergedInputRef}type="text"+ // Autocorrect would rewrite names and identifiers.+ {...textEntryTraitAttributes({+ enterKeyHint: 'search',+ hasAutoCorrect: false,+ })}aria-label={label}placeholder={placeholder}value={value}diff --git a/packages/core/src/Field/__tests__/SearchKeyboard.interaction.browser.spec.ts b/packages/core/src/Field/__tests__/SearchKeyboard.interaction.browser.spec.tsnew file mode 100644index 0000000000..3bb5d5df49--- /dev/null+++ b/packages/core/src/Field/__tests__/SearchKeyboard.interaction.browser.spec.ts@@ -0,0 +1,83 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file SearchKeyboard.interaction.browser.spec.ts+ * @input Storybook stories of Typeahead, Tokenizer, Selector, MultiSelector+ * and CommandPaletteInput+ * @output On a touch-emulated phone, the search input that a tap focuses+ * carries `enterkeyhint="search"` and `autocorrect="off"`+ * @position Search keyboard evidence in the interaction lane. jsdom has no+ * touch input and no real focus.+ */++import {expect, test, type Locator, type Page} from '@playwright/test';+import {openStory, withStorybook} from '@astryxdesign/interaction-harness';++const storybook = withStorybook(test);++async function expectSearchKeyboard(input: Locator) {+ await expect(input).toHaveCount(1);+ await expect(input).toBeVisible();+ await input.tap();+ await expect(input).toBeFocused();+ await expect(input).toHaveAttribute('enterkeyhint', 'search');+ await expect(input).toHaveAttribute('autocorrect', 'off');+}++async function openSearchRow(page: Page, story: string, label: string) {+ await openStory(page, storybook(), story);+ const trigger = page.getByRole('button', {name: label, exact: true});+ await expect(trigger).toBeVisible();+ await trigger.tap();+ return page.getByRole('combobox');+}++test('a tap on Typeahead focuses a field that asks for the Search key and no autocorrection', async ({+ page,+}) => {+ await openStory(page, storybook(), 'core-typeahead--default');+ await expectSearchKeyboard(page.getByRole('combobox'));+});++test('a tap on Tokenizer focuses a field that asks for the Search key and no autocorrection', async ({+ page,+}) => {+ await openStory(page, storybook(), 'core-tokenizer--default');+ await expectSearchKeyboard(page.getByRole('combobox'));+});++test("a tap in Selector's search row focuses a field that asks for the Search key and no autocorrection", async ({+ page,+}) => {+ const search = await openSearchRow(+ page,+ 'core-selector--searchable',+ 'Fruit',+ );+ await expectSearchKeyboard(search);+});++test("a tap in MultiSelector's search row focuses a field that asks for the Search key and no autocorrection", async ({+ page,+}) => {+ const search = await openSearchRow(+ page,+ 'core-multiselector--searchable',+ 'Countries',+ );+ await expectSearchKeyboard(search);+});++test('a tap on a standalone CommandPaletteInput focuses a field that asks for the Search key and no autocorrection', async ({+ page,+}) => {+ await openStory(page, storybook(), 'core-commandpaletteinput--standalone');+ await expectSearchKeyboard(page.getByRole('searchbox'));+});++test('a tap on CommandPaletteInput inside a palette focuses a field that asks for the Search key and no autocorrection', async ({+ page,+}) => {+ await openStory(page, storybook(), 'core-commandpaletteinput--popup-context');+ await expectSearchKeyboard(page.getByRole('combobox'));+});diff --git a/packages/core/src/Field/textEntryTraits.ts b/packages/core/src/Field/textEntryTraits.tsindex 3855c77bc0..26f86c5d1d 100644--- a/packages/core/src/Field/textEntryTraits.ts+++ b/packages/core/src/Field/textEntryTraits.ts@@ -3,16 +3,16 @@/*** @file textEntryTraits.ts* @input The keyboard-trait props a text field accepts- * @output Exports the closed value unions EnterKeyHint, InputMode and- * AutoCapitalize (the package entry exports these three), the fields' prop- * mixin TextEntryTraitProps, and textEntryTraitAttributes, which maps the- * props onto the native attributes of the editable element- * @position Shared by TextInput and TextArea: the one place that says how a- * field tells a touch keyboard what it holds+ * @output EnterKeyHint, InputMode and AutoCapitalize (the package entry exports+ * these), TextEntryTraitProps and textEntryTraitAttributes+ * @position Shared by TextInput, TextArea and the search inputs: the one place+ * that says how a field tells a touch keyboard what it holds** SYNC: When modified, update:* - /packages/core/src/TextInput/TextInput.tsx and TextInput.doc.mjs* - /packages/core/src/TextArea/TextArea.tsx and TextArea.doc.mjs+ * - /packages/core/src/Typeahead/BaseTypeahead.tsx, Field/PanelSearchInput.tsx+ * and CommandPalette/CommandPaletteInput.tsx (the search inputs)* - /packages/core/src/Field/index.ts (type exports)*/diff --git a/packages/core/src/MultiSelector/MultiSelector.test.tsx b/packages/core/src/MultiSelector/MultiSelector.test.tsxindex d34845d29d..b866115302 100644--- a/packages/core/src/MultiSelector/MultiSelector.test.tsx+++ b/packages/core/src/MultiSelector/MultiSelector.test.tsx@@ -1019,6 +1019,30 @@ describe('MultiSelector', () => {expect(onChange).toHaveBeenCalledWith(['Apple', 'Banana', 'Orange']);});+ it('asks a touch keyboard for its Search key and no autocorrection in the search row, and Enter still toggles the highlighted option', async () => {+ const user = userEvent.setup();+ const onChange = vi.fn();+ render(+ <MultiSelector+ label="Fruit"+ options={defaultOptions}+ value={[]}+ onChange={onChange}+ hasSearch+ />,+ );+ await user.click(screen.getByRole('button', {name: 'Fruit'}));+ const search = screen.getByRole('combobox', h);+ expect(search).toHaveAttribute('enterkeyhint', 'search');+ expect(search).toHaveAttribute('autocorrect', 'off');++ await user.type(search, 'ban');+ await user.keyboard('{ArrowDown}');+ expect(search).toHaveAttribute('aria-activedescendant');+ fireEvent.keyDown(search, {key: 'Enter'});+ expect(onChange).toHaveBeenCalledWith(['Banana']);+ });+it('renders search input when hasSearch', async () => {const user = userEvent.setup();render(diff --git a/packages/core/src/Selector/Selector.test.tsx b/packages/core/src/Selector/Selector.test.tsxindex 943eef22a0..d3fb508c47 100644--- a/packages/core/src/Selector/Selector.test.tsx+++ b/packages/core/src/Selector/Selector.test.tsx@@ -1077,6 +1077,30 @@ describe('Selector', () => {expect(screen.getByRole('combobox', h)).toBeInTheDocument();});+ it('asks a touch keyboard for its Search key and no autocorrection in the search row, and Enter still selects the highlighted option', async () => {+ const user = userEvent.setup();+ const onChange = vi.fn();+ render(+ <Selector+ label="Fruit"+ options={OPTIONS}+ value="Apple"+ onChange={onChange}+ hasSearch+ />,+ );+ await user.click(screen.getByRole('button', {name: 'Fruit'}));+ const search = screen.getByRole('combobox', h);+ expect(search).toHaveAttribute('enterkeyhint', 'search');+ expect(search).toHaveAttribute('autocorrect', 'off');++ await user.type(search, 'ban');+ await user.keyboard('{ArrowDown}');+ expect(search).toHaveAttribute('aria-activedescendant');+ fireEvent.keyDown(search, {key: 'Enter'});+ expect(onChange).toHaveBeenCalledWith('Banana');+ });+// The search input's expanded state, popup relationship, and active option// are bound to the shared Combobox contract (Selector.combobox.a11y.test.tsx,// search-active); this keeps only the Selector-specific wiring.diff --git a/packages/core/src/Tokenizer/Tokenizer.test.tsx b/packages/core/src/Tokenizer/Tokenizer.test.tsxindex 7c762b32aa..0c2fe36f5b 100644--- a/packages/core/src/Tokenizer/Tokenizer.test.tsx+++ b/packages/core/src/Tokenizer/Tokenizer.test.tsx@@ -200,6 +200,32 @@ describe('Tokenizer press inside and outside', () => {});describe('Tokenizer', () => {+ it('asks a touch keyboard for its Search key and no autocorrection, and Enter still adds the highlighted result', async () => {+ const onChange = vi.fn();+ render(+ <Tokenizer+ label="Members"+ searchSource={userSource}+ value={[users[0]]}+ onChange={onChange}+ debounceMs={0}+ />,+ );+ const input = screen.getByRole('combobox');+ expect(input).toHaveAttribute('enterkeyhint', 'search');+ expect(input).toHaveAttribute('autocorrect', 'off');++ fireEvent.change(input, {target: {value: 'Bob'}});+ await waitFor(() => {+ expect(input).toHaveAttribute('aria-expanded', 'true');+ });+ fireEvent.keyDown(input, {key: 'Enter'});+ expect(onChange).toHaveBeenCalledWith(+ [users[0], expect.objectContaining({label: 'Bob'})],+ expect.objectContaining({type: 'add'}),+ );+ });+it('forwards DOM props and ref to the combobox input while preserving focus callbacks', () => {const ref = createRef<HTMLInputElement>();const onClick = vi.fn();diff --git a/packages/core/src/Typeahead/BaseTypeahead.test.tsx b/packages/core/src/Typeahead/BaseTypeahead.test.tsxindex 217fcdd93b..6e8a9653e6 100644--- a/packages/core/src/Typeahead/BaseTypeahead.test.tsx+++ b/packages/core/src/Typeahead/BaseTypeahead.test.tsx@@ -88,6 +88,25 @@ const testStyles = stylex.create({});describe('BaseTypeahead', () => {+ it('asks a touch keyboard for its Search key and no autocorrection', () => {+ render(+ <BaseTypeahead+ searchSource={emptySource}+ value={null}+ onChange={() => {}}+ aria-label="Find a framework"+ />,+ );++ expect(+ screen.getByRole('combobox', {name: 'Find a framework'}),+ ).toHaveAttribute('enterkeyhint', 'search');++ expect(+ screen.getByRole('combobox', {name: 'Find a framework'}),+ ).toHaveAttribute('autocorrect', 'off');+ });+it('forwards supported DOM, styling, and event props to the combobox input', () => {const onBlur = vi.fn();const onFocus = vi.fn();diff --git a/packages/core/src/Typeahead/BaseTypeahead.tsx b/packages/core/src/Typeahead/BaseTypeahead.tsxindex 17ba968f05..554d8be98d 100644--- a/packages/core/src/Typeahead/BaseTypeahead.tsx+++ b/packages/core/src/Typeahead/BaseTypeahead.tsx@@ -79,6 +79,7 @@ import {useComponentTranslator,} from '../i18n/useComponentTranslator';import english from '../i18n/generated-english/Typeahead/BaseTypeahead.generated';+import {textEntryTraitAttributes} from '../Field/textEntryTraits';registerEnglishFallback(english);// =============================================================================@@ -1723,6 +1724,12 @@ export const BaseTypeahead = function BaseTypeahead<T extends SearchableItem>({autoFocus={hasAutoFocus}data-autofocus={hasAutoFocus || undefined}autoComplete="off"+ // Autocorrect would rewrite names and identifiers. The key is only a+ // label: Enter still commits the highlighted option.+ {...textEntryTraitAttributes({+ enterKeyHint: 'search',+ hasAutoCorrect: false,+ })}{...mergeProps(stylex.props(styles.input,diff --git a/packages/core/src/Typeahead/Typeahead.test.tsx b/packages/core/src/Typeahead/Typeahead.test.tsxindex ef93057ebe..3cb0a601e3 100644--- a/packages/core/src/Typeahead/Typeahead.test.tsx+++ b/packages/core/src/Typeahead/Typeahead.test.tsx@@ -720,6 +720,31 @@ describe('BaseTypeahead focus-out', () => {});describe('Typeahead', () => {+ it('asks a touch keyboard for its Search key and no autocorrection, and Enter still picks the highlighted result', async () => {+ const onChange = vi.fn();+ render(+ <Typeahead+ label="Fruit"+ searchSource={fruitSource}+ value={null}+ onChange={onChange}+ debounceMs={0}+ />,+ );+ const input = screen.getByRole('combobox', {name: 'Fruit'});+ expect(input).toHaveAttribute('enterkeyhint', 'search');+ expect(input).toHaveAttribute('autocorrect', 'off');++ fireEvent.change(input, {target: {value: 'App'}});+ await waitFor(() => {+ expect(input).toHaveAttribute('aria-expanded', 'true');+ });+ fireEvent.keyDown(input, {key: 'Enter'});+ expect(onChange).toHaveBeenCalledWith(+ expect.objectContaining({label: 'Apple'}),+ );+ });+describe('out-of-order async results', () => {it('discards a stale response that resolves after a newer query', async () => {const resolvers = new Map<string, (items: SearchableItem[]) => void>();