Skip to content

[web] There seems to be no way for a user to manually enter a newline into a TextField on the web #167902

@csells

Description

@csells

Steps to reproduce

  1. Run the following program on macOS:
import 'package:flutter/material.dart';

void main() => runApp(_MainApp());

class _MainApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) => MaterialApp(
    home: Scaffold(
      body: TextField(
        maxLines: null, // or pick a number
        textInputAction: TextInputAction.done,
        onSubmitted: debugPrint,
      ),
    ),
  );
}

Pressing Enter triggers onSubmitted as expected and pressing Ctrl+Enter or Opt+Enter adds a newline to the text input on macOS.

  1. Run the same code on web and Ctrl+Enter and Opt+Enter (as well as Shift+Enter and Cmd+Enter) trigger onSubmitted instead of adding a newline to the text input.

Expected results

When a TextField is set to enable multi-line input, the user should be able to manually add a newline to the text input, e.g. via Ctrl+Enter, Opt+Enter, Shift+Enter, etc.

Actual results

as stated

Code sample

as shown

Screenshots or Video

No response

Logs

Logs
Launching lib/echo/echo.dart on Chrome in debug mode...
This app is linked to the debug service: ws://127.0.0.1:53276/niZQJMCBLcg=/ws
Debug service listening on ws://127.0.0.1:53276/niZQJMCBLcg=/ws
Connecting to VM Service at ws://127.0.0.1:53276/niZQJMCBLcg=/ws
Connected to the VM Service.

Chrome: Version 135.0.7049.115 (Official Build) (arm64)
macOS: version 15.4.1 (24E263)

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.29.3, on macOS 15.4.1 24E263 darwin-arm64, locale en-US) [316ms]
    • Flutter version 3.29.3 on channel stable at /Users/csells/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ea121f8859 (2 weeks ago), 2025-04-11 19:10:07 +0000
    • Engine revision cf56914b32
    • Dart version 3.7.2
    • DevTools version 2.42.3

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [1,408ms]
    • Android SDK at /Users/csells/Library/Android/sdk
    • Platform android-35, build-tools 35.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.3) [742ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16E140
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [11ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.2) [10ms]
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)

[✓] VS Code (version 1.99.2) [8ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.108.0

[✓] Connected device (3 available) [5.9s]
    • macOS (desktop)                 • macos                 • darwin-arm64   • macOS 15.4.1
      24E263 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin         • macOS 15.4.1
      24E263 darwin-arm64
    • Chrome (web)                    • chrome                • web-javascript • Google Chrome
      135.0.7049.115

[✓] Network resources [670ms]
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

Labels

a: text inputEntering text in a text field or keyboard related problemsplatform-webWeb applications specificallyr: solvedIssue is closed as solvedteam-webOwned by Web platform teamworkaround availableThere is a workaround available to overcome the issue

Type

Projects

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions