Repository navigation
Description
Context
Part of #2576. #1810 owns the Composer textarea. This task covers every other custom Enter handler on a text field.
These handlers act on Enter without checking for an active IME composition. A user confirming a Japanese, Chinese or Korean candidate therefore submits, saves or renames with half-composed text:
| Site | Action on Enter |
|---|---|
(SkillsList, packages/ui-react/src/components/settings/skills-list.tsx:67-69) |
create skill |
skills-list.tsx:109-111 |
install from GitHub |
(OpenRouterSection, packages/ui-react/src/components/settings/models-list.tsx:189-191) |
add model |
(KeyEditor, packages/ui-react/src/components/settings/web-search-chain.tsx:262-264) |
save API key |
(PasskeyRow, packages/ui-react/src/components/settings/passkey-list.tsx:149-152) |
commit rename (Escape cancels it) |
(handleKeyDown, packages/ui-react/src/components/quick-actions/search-modal.tsx:148-166) |
open result or run search |
(onKeyDown, packages/ui-react/src/components/layout/desktop-palette.tsx:146-156) |
activate palette row |
(TagsField, packages/ui-react/src/components/settings/module-settings-fields.tsx:177) |
add tag |
(AskOtherField, packages/ui-kit/src/internal/AskOtherField.tsx:41-45) |
submit "Other" answer. It checks isComposing only when p.value !== undefined, so the uncontrolled field is unguarded. |
(onKeyDown, packages/ui-react/src/components/quick-actions/add-form.tsx:58-64) |
Cmd/Ctrl+Enter save |
No enterKeyHint is set anywhere in either package (grep -rn enterKeyHint packages/ui-*/src is empty), so Android keyboards show a generic return key even where Enter sends, searches or saves.
Guide forms/ime-safe-enter-submit: "The composition-active check applies to any custom keydown handler that acts on Enter, not only to multiline <textarea> fields". The guide recommends pairing event.isComposing with event.keyCode === 229 to catch Safari's out-of-order confirming Enter. Guide forms/forms: "DO use enterkeyhint to set the Enter key label".
Scope
- Add one helper in
packages/ui-kit/src/internal/that returns true when a key event is composing:nativeEvent.isComposing || keyCode === 229, evaluated only after the key is known to be Enter or Escape. Export it through@schlessera/brain-ui-kit/internalfor ui-react. - Every site in the table returns early on a composing Enter. Where the site handles Escape (passkey rename), it also returns early on a composing Escape. It returns before calling
preventDefault(), so the IME keeps its own default. AskOtherFieldchecks composition in both controlled and uncontrolled use.- Add
enterKeyHint:"send"on the kit Composer textarea (Enter sends at every width),"search"on the search modal,"go"on the desktop palette and the GitHub install field, and"done"on the remaining single-value fields.
Out of scope
- The Composer's Enter/Escape composition handling (ui-kit: Composer shortcuts send or stop during IME composition #1810). Only the
enterKeyHintattribute is added toComposer.tsxhere. - Enter on non-text elements (rows, cards, radios). Those keys do not come from an IME.
- Converting these inputs to
<form>implicit submission.
Acceptance criteria
- Every row in the table uses the shared helper.
grep -rn '"Enter"' packages/ui-react/srcshows no text-field handler without it. - A composing Enter (and, for the passkey rename, a composing Escape) does not run the action and does not call
preventDefault(). A plain Enter runs it once. - A browser test uses CDP
Input.imeSetCompositionwith trusted keys, the method ui-kit: Composer shortcuts send or stop during IME composition #1810 used, on at least the search modal and the uncontrolledAskOtherField. It fails on the current tree (the action runs) and passes after. A mutation that removes the helper's check makes it fail again. Record both in the PR. - The
enterKeyHintvalues above are present in the rendered DOM. - Changeset for both packages (patch).
Verification
bun run test packages/ui-kit packages/ui-react
node scripts/visual.mjs --project=ui-react-layout
bun run typecheck
bun run lint
bun run check:pr --base origin/mainContract impact
- This touches the integration contract, so it needs the
contractlabel, aCONTRACT:commit prefix, and the doc updated in the same commit. - This changes a published package's behaviour, so it needs a changeset.
No API changes. The helper ships on the unsupported /internal entry.
Activity