Skip to content

[Web] TextField receiving newline on TextInputAction.next #113559

@PauloZung

Description

@PauloZung

In a form with two consecutive TextFields with TextInputAction.next, pressing Return on the first field, inserts a newLine on the second after advancing focus.

The only way to avoid this problem is setting maxLines=1 on every field, preventing multiline inputs from being used.

Steps to Reproduce

  1. Execute flutter run on the code sample (web Chrome).
  2. Set focus on the first field (with "A")
  3. Press enter/return on the physical keyboard to move focus to next field ("B")
  4. Type "123"

Expected results:

The second field with the content "B123".

Actual results:

The second field with the content "B{newline}123".

Code sample
import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) => const MaterialApp(title: 'Input Error Demo', home: Home());
}

class Home extends StatefulWidget {
  const Home({Key? key}) : super(key: key);
  @override
  State<Home> createState() => _HomeState();
}

class _HomeState extends State<Home> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Input Error Demo')),
      body: Column(
        children: [
          TextFormField(
            initialValue: "A",
            textInputAction: TextInputAction.next,
          ),
          TextFormField(
            initialValue: "B",
            minLines: 2,
            maxLines: 2,
            textInputAction: TextInputAction.next,
          ),
        ],
      ),
    );
  }
}
Logs
flutter doctor -v
[✓] Flutter (Channel stable, 3.3.4, on macOS 12.6 21G115 darwin-x64, locale pt-BR)
    • Flutter version 3.3.4 on channel stable at /Users/paulo/Documents/Desenvolvimento/flutter_sdks/flutter_3.3.4
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision eb6d86ee27 (13 days ago), 2022-10-04 22:31:45 -0700
    • Engine revision c08d7d5efc
    • Dart version 2.18.2
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/paulo/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 13F100
    • CocoaPods version 1.11.3

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

[✓] Android Studio (version 2021.2)
    • 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 11.0.12+0-b1504.28-7817840)

[✓] VS Code (version 1.72.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.50.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 12.6 21G115 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 106.0.5249.119

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Captura de Tela 2022-10-17 às 15 09 09

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsengineflutter/engine related. See also e: labels.found in release: 3.3Found to occur in 3.3found in release: 3.5Found to occur in 3.5has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallywaiting for PR to land (fixed)A fix is in flight

Type

No type

Projects

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions