Skip to content

feat: TextField.text_input_action to choose the action button of the mobile onscreen keyboard - #7021

Merged
FeodorFitsner merged 4 commits into
flet-1.1.0from
feat/textfield-text-input-action-6962
Oct 29, 2026
Merged

FeodorFitsner merged 4 commits into
flet-1.1.0from
feat/textfield-text-input-action-6962

Conversation

@ndonkoHenri

@ndonkoHenri ndonkoHenri commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #6962.

On a phone, a single-line TextField always shows Done on the keyboard, and pressing it closes the keyboard. Moving to the next field from on_submit with focus() can't avoid that: by the time the call comes back from Python, Flutter has already dropped focus and is hiding the keyboard, so it closes and reopens on every field.

This adds text_input_action to TextField and CupertinoTextField, with a TextInputAction enum that mirrors Flutter's. With NEXT, Flutter moves focus to the next field in the same frame, so the keyboard stays open, and on_submit still fires:

ft.TextField(label="Name", text_input_action=ft.TextInputAction.NEXT)
ft.TextField(label="Email", text_input_action=ft.TextInputAction.NEXT)
ft.TextField(label="Message", text_input_action=ft.TextInputAction.SEND, on_submit=send)

When it isn't set, fields behave as before: Done on single-line fields, a new line on multiline ones.

Changes

  • Python: TextInputAction enum and TextField.text_input_action. The field is keyword-only, so the positional arguments of TextField and its subclass CupertinoTextField don't shift.
  • Dart: parseTextInputAction() / Control.getTextInputAction(), passed to TextFormField and CupertinoTextField.
  • Docs: the enum docs say what each action does with focus and which platforms support it, and a new keyboard_actions example is shown on the TextField and TextInputAction pages.

Testing

Tested with a probe app on the iOS Simulator (iOS 26.5, debug build) and an Android 16 emulator (release APK):

  • NEXT moves focus with the keyboard open the whole time (checked on every frame of a screen recording on iOS, and by polling the IME state on Android), and on_submit fires.
  • DONE, GO, SEARCH and SEND close the keyboard after on_submit, and each shows its own key.
  • PREVIOUS (Android), CupertinoTextField, multiline fields (no new line and no on_submit with DONE/NEXT), and changing the action at runtime (applies on the next focus) all behave as documented.
  • Fields without the property are unchanged.

Web was tested earlier in headless Chromium: the browser gets the matching enterkeyhint, and Enter performs the action.

Things worth knowing

  • In a debug build, an action the platform doesn't support (such as PREVIOUS on iOS) leaves the field focused with no keyboard and no error. Android release builds fall back to the default key. This is documented on the enum.
  • NEXT follows reading order, so a focusable suffix button gets focus before the next field. Flet has no way to take a button out of focus traversal, so that would be a separate feature.
  • On multiline fields the action key never calls on_submit, because Flet only wires it for single-line fields. That predates this change.

Summary by Sourcery

Enable configurable onscreen keyboard actions for text fields, including seamless focus chaining between form fields.

New Features:

  • Add a TextInputAction enum and text_input_action property to TextField and CupertinoTextField for selecting mobile keyboard actions and controlling focus behavior.

Enhancements:

  • Support parsing the configured text input action across native text field controls while preserving existing defaults when unset.

Documentation:

  • Document TextInputAction behavior, platform support, and keyboard-action form usage with a new example and reference page.

TextField and CupertinoTextField always used the platform's default
keyboard action, so a form couldn't offer "Next" to move to the next
field with the keyboard open. `text_input_action` takes the new
TextInputAction enum and is passed to Flutter's textInputAction; None
keeps the platform default.
…ample

Device tests on the iOS Simulator and an Android emulator showed what the
enum docs left out: an action the platform doesn't support leaves a debug
build's field without a keyboard and reports no error, CONTINUE_ACTION,
JOIN, ROUTE, EMERGENCY_CALL and UNSPECIFIED keep focus and the keyboard
open, and NONE on Android removes focus. Platform-only actions now say so
in a Note.

The new keyboard_actions example chains a form with NEXT and sends it with
SEND. It is shown on the TextField and TextInputAction pages.

@sourcery-ai sourcery-ai Bot 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.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@ndonkoHenri ndonkoHenri changed the title Add text_input_action to TextField feat: TextField.text_input_action to choose the action button of the mobile onscreen keyboard Oct 28, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Deploying flet-website-v2 with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4190d4e
Status: ✅  Deploy successful!
Preview URL: https://bec3846a.flet-website-v2.pages.dev
Branch Preview URL: https://feat-textfield-text-input-ac.flet-website-v2.pages.dev

View logs

@FeodorFitsner
FeodorFitsner merged commit abbb238 into flet-1.1.0 Oct 29, 2026
2 of 104 checks passed
@FeodorFitsner
FeodorFitsner deleted the feat/textfield-text-input-action-6962 branch October 29, 2026 18:21
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.

feature: text_input_action for TextField, so a keyboard's "Next" button can move to the next field seamlessly

2 participants