Skip to content

Add keyboardType, submitLabel, and onSubmit#63

Merged
colemancda merged 5 commits into
masterfrom
feature/form-input
Jul 24, 2026
Merged

Add keyboardType, submitLabel, and onSubmit#63
colemancda merged 5 commits into
masterfrom
feature/form-input

Conversation

@colemancda

Copy link
Copy Markdown
Member

The form-input batch for text entry: .keyboardType(_:), .submitLabel(_:), and .onSubmit(perform:). All three are read by the field off its own modifier list, the same way .focused already is.

Mapping

  • keyboardType → Compose KeyboardType (.decimalPad→Decimal, .numberPad→Number, .emailAddress→Email, .URL→Uri, .phonePad→Phone, else Text). UIKeyboardType is defined with SwiftUI's spelling so call sites port unchanged.
  • submitLabel → the field's ImeAction (.search→Search, .go→Go, .send→Send, .next→Next, else Done), which names the keyboard's action key.
  • onSubmit → a void callback wired to every KeyboardActions handler, so it fires whatever action key the submit label selected.

The field is now singleLine = true, which is what makes the IME show an action key rather than a newline key.

Verification

  • swift test — 2 new tests (type/label spelling emit; onSubmit registers a callable callback), 112 passing.
  • Emulator, verified against the real IME, not just the render:
    • focusing the .decimalPad field, dumpsys input_method reported inputType=0x2002TYPE_CLASS_NUMBER | TYPE_NUMBER_FLAG_DECIMAL, i.e. the decimal pad reached the IME
    • typing in the .submitLabel(.search) field and pressing the action key fired onSubmit, incrementing the on-screen counter to 1

Scope

The common keyboard types and submit labels; exotic UIKeyboardType cases fall back to the text keyboard. onSubmit(of:) (the search-vs-text trigger variant) isn't modeled — this is the plain onSubmit. Note the submitted-text binding can lag by a keystroke if the last onChange hasn't round-tripped before submit reads it — the async text-echo path, not specific to this change.

@colemancda
colemancda merged commit 8b08220 into master Jul 24, 2026
6 checks passed
@colemancda
colemancda deleted the feature/form-input branch July 24, 2026 09:25
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