Skip to content

Upon tapping a TextField, the cursor appears on left side of text if text is exactly one character long #115702

@benji-farquhar

Description

@benji-farquhar

Steps to Reproduce

  1. Enter EXACTLY one character into the TextField
  2. Press enter to unfocus the TextField
  3. Tap on the Textfield to give it focus

Expected results: The cursor appears in the TextField on the right side of the text.

Actual results: The cursor appears in the TextField on the left side of the text. Note that if there are two or more characters, the cursor appears on the right side of the text.

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

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  final String title;

  const MyHomePage({super.key, required this.title});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: const Center(
          child: TextField(
        decoration: InputDecoration(
          border: OutlineInputBorder(),
          hintText: 'Enter a search term',
        ),
      )),
    );
  }
}

Logs
Doctor summary (to see all details, run flutter doctor -v):

[✓] Flutter (Channel master, 3.4.0-29.0.pre.55, on macOS 13.0.1 22A400 darwin-arm64, locale en-GB)
    • Flutter version 3.4.0-29.0.pre.55 on channel master at /Users/benjaminfarquhar/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision d98b0c9c7c (9 weeks ago), 2022-09-20 23:35:24 -0400
    • Engine revision 38fef0572f
    • Dart version 2.19.0 (build 2.19.0-223.0.dev)
    • DevTools version 2.17.0

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

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

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

[✓] Android Studio (version 2021.1)
    • 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.11+0-b60-7772763)

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

[✓] Connected device (5 available)
    • iPhone 14 (mobile)                             • AFAF79C5-E179-4196-BA64-D1B207492B8B • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-16-1 (simulator)
    • iPhone 14 Pro (mobile)                         • 7C18494E-7E52-482C-B49F-31495FA29DE0 • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-16-1 (simulator)
    • iPad Pro (12.9-inch) (6th generation) (mobile) • C23FED79-28C8-4B6C-BD33-A8E6F19CF770 • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-16-1 (simulator)
    • macOS (desktop)                                • macos                                • darwin-arm64   • macOS 13.0.1 22A400 darwin-arm64
    • Chrome (web)                                   • chrome                               • web-javascript • Google Chrome 107.0.5304.110

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

• No issues found!
Simulator.Screen.Recording.-.iPhone.14.-.2022-11-20.at.07.29.48.mp4

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsc: regressionIt was better in the past than it is nowengineflutter/engine related. See also e: labels.found in release: 3.6Found to occur in 3.6has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specificallyr: fixedIssue is closed as already fixed in a newer version

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions