Skip to content

[web]: TextField onSubmitted is not triggered when pressing enter #35435

@deckerst

Description

@deckerst

On mobile, pressing the enter key while editing a TextField triggers onSubmitted.
On the web, it is never called.

Example:

        body: TextField(
          onSubmitted: (s) {
            // this is never called
            debugPrint('onSubmitted s=$s');
          },
        ),

In the meantime, there's a workaround with RawKeyboardListener:

        body: RawKeyboardListener(
          focusNode: focusNode,
          onKey: (event) {
            if (event is RawKeyUpEvent && event.data is RawKeyEventDataAndroid) {
              var data = event.data as RawKeyEventDataAndroid;
              if (data.keyCode == 13) {
                debugPrint('onSubmitted');
              }
            }
          },
          child: TextField(),
        ),

But it would be nice if it was natively handled.

By the way, contrary to #19027 there is absolutely no log when pressing enter. Nothing like inactive InputConnection, etc.

edit:
flutter_web version: commit 1ed4317 (June 22)
Mac OS X 10.14.5 18F132, locale en-KR

Metadata

Metadata

Assignees

Labels

a: text inputEntering text in a text field or keyboard related problemsplatform-webWeb applications specifically

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions