Skip to content

feat: honor TextField text_input_action keyboard actions - #14

Merged
AdamMusa merged 2 commits into
codex/engine-initializationfrom
feat/text-input-action
Oct 29, 2026
Merged

AdamMusa merged 2 commits into
codex/engine-initializationfrom
feat/text-input-action

Conversation

@AdamMusa

@AdamMusa AdamMusa commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Ruby counterpart: AdamMusa/ruflet#30

What

TextField now honors the Ruby text_input_action keyword: it picks the soft keyboard's return key (Done, Next, Send, Search, ...) and, through Flutter's default editing-complete behavior, moves focus to the next or previous field.

Wire keys and events

Key / event Type Notes
text_input_action String or absent Matches Flutter TextInputAction names case-insensitively. camelCase or snake_case both work (continueAction / continue_action). Absent or unknown values keep the platform default.
submit (unchanged) payload = text Fires on every keyboard action that ends editing, including next/previous.

Supported values: done go search send next previous newline unspecified none continueAction join route emergencyCall.

Material vs Cupertino

  • Material (TextFormField) and Cupertino (CupertinoTextField) both receive the parsed action.
  • The action is checked against the device keyboard (defaultTargetPlatform), not the page's design platform. A page can force the Cupertino design on an Android phone, but the Android keyboard still asserts on iOS-only actions. Unsupported actions become null (platform default), mirroring Flutter's lists in services/text_input.dart:
    • Android drops continueAction join route emergencyCall.
    • iOS drops none previous.
    • Desktop and other platforms pass everything through.
  • onEditingComplete is intentionally not set, so Flutter's default handles focus: next calls nextFocus(), previous calls previousFocus(), other actions unfocus. onSubmitted still runs, so Ruby's on_submit fires.
  • multiline: true plus an explicit ending action (anything except newline/unspecified/none) now submits on Return instead of inserting a newline. This matches iOS, where a non-default return key sends the action rather than \n. Without text_input_action, multiline fields behave as before (Return inserts a newline, no submit).

Changes

  • utils/input.dart: parseTextInputAction(String?, TargetPlatform) (strips underscores per SPEC R4, filters by platform), textInputActionEndsMultilineEditing, Control.getTextInputAction. The file stays import-neutral (foundation/services/widgets only).
  • controls/textfield.dart, controls/cupertino_textfield.dart: pass textInputAction; keep the submit callback for multiline fields with an ending action.

Tests

test/widgets/ruby_text_input_action_test.dart (9 tests, run on iOS and Android via TargetPlatformVariant):

  • Parser: camelCase, snake_case and mixed case; null and unknown values; the full Android and iOS allow-lists; desktop passthrough.
  • Per design, asserting the renderer is CupertinoTextField on iOS and TextField on Android:
    • next moves focus from field A to B. A fires submit("[email protected]") and blur, B fires focus. Then done on B unfocuses it and fires submit("secret").
    • Sanitizing: EditableText.textInputAction for previous, join, emergency_call and Search, plus null when the key is absent.
    • Multiline + done submits the text without inserting a newline. Multiline without an action never submits on newline.
  • Android: previous moves focus back to the preceding field and submits.

verify_pr.sh (Flutter 3.41.2), run together with the Ruby PR:

PASS ruby:ruflet_core                   146/146 files, 624 runs
PASS engine:ruflet flutter test         +704: All tests passed!
PASS engine:ruflet analyze              No issues found!
INFO wire-key audit                     NEW vs baseline: 0
RESULT: PASS

Read the Ruby text_input_action keyword on both TextField renderers and
pass it to TextFormField/CupertinoTextField. Values accept camelCase or
snake_case and are sanitized for the device keyboard (Flutter asserts on
actions a platform does not support), so unsupported actions fall back
to the platform default.

next/previous use Flutter's default focus traversal and still fire
submit. A multiline field with an explicit action such as done now
submits on Return instead of inserting a newline.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant