Skip to content

tap to move cursor in textfield not working on android #100004

Closed

Description

@Fnalsk

Steps to Reproduce

This only seems to happen on physical devices. So far it has occurred with the s8 and the s10. Unsure if the issue can be reproduced elsewhere, but it does not occur in ios simulator, physical ios, or android emulator.

  1. Create a TextField widget and type something in it
  2. Tap somewhere in the middle of the text you just typed, with the intention of moving the cursor to where you tapped

Expected results:
Cursor moves to the location that was tapped
Actual results:
The text between where you tapped and the last character in the textfield gets selected (highlighted).

Because of this issue it's very difficult for a user to go back and fix typos and such.

Activity

  1. maheshj01 commented on Mar 14, 2022

    @maheshj01
    Member

    Hi @Fnalsk, I am unable to reproduce the issue on ios or Android on the latest stable channel of flutter 2.10.3. Please share the output of flutter doctor -v.

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Mar 14, 2022
  3. Fnalsk commented on Mar 15, 2022

    @Fnalsk
    Author
    [✓] Flutter (Channel stable, 2.10.3, on macOS 12.2.1 21D62 darwin-arm, locale en)
        • Flutter version 2.10.3 at /Users/alpha/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 7e9793dee1 (12 days ago), 2022-03-02 11:23:12 -0600
        • Engine revision bd539267b4
        • Dart version 2.16.1
        • DevTools version 2.9.2
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0-rc2)
        • Android SDK at /Users/alpha/Library/Android/sdk
        • Platform android-31, build-tools 31.0.0-rc2
        • ANDROID_HOME = /Users/alpha/Library/Android/sdk
        • ANDROID_SDK_ROOT = /Users/alpha/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • CocoaPods version 1.11.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2020.3)
        • 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.10+0-b96-7249189)
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2021.2.3)
        • IntelliJ at /Applications/IntelliJ IDEA.app
        • Flutter plugin version 61.2.4
        • Dart plugin version 212.5632
    
    [✓] Connected device (3 available)
        • iPhone 13 Pro Max (mobile) • 6AE162EB-DD70-45E3-AF99-A12356B6EB9B • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-2 (simulator)
        • macOS (desktop)            • macos                                • darwin-arm64   • macOS 12.2.1 21D62 darwin-arm
        • Chrome (web)               • chrome                               • web-javascript • Google Chrome 99.0.4844.51
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    • No issues found!
    
    
  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Mar 15, 2022
  5. maheshj01 commented on Mar 15, 2022

    @maheshj01
    Member

    @Fnalsk Please share the minimal reproducible code sample. I am unable to reproduce this issue with the below code sample.

    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) {
        return MaterialApp(
          title: 'Flutter Demo',
          theme: ThemeData(
            primarySwatch: Colors.blue,
          ),
          home: const MyHomePage(),
        );
      }
    }
    
    class MyHomePage extends StatefulWidget {
      const MyHomePage({Key? key}) : super(key: key);
    
      @override
      State<MyHomePage> createState() => _MyHomePageState();
    }
    
    class _MyHomePageState extends State<MyHomePage> {
      @override
      Widget build(BuildContext context) {
        return Scaffold(body: Center(child: TextField()));
      }
    }
    
    flutter doctor -v (mac)
    [✓] Flutter (Channel stable, 2.10.3, on macOS 12.1 21C52 darwin-arm, locale en-GB)
        • Flutter version 2.10.3 at /Users/mahesh/Documents/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 7e9793dee1 (20 hours ago), 2022-03-02 11:23:12 -0600
        • Engine revision bd539267b4
        • Dart version 2.16.1
        • DevTools version 2.9.2
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-31, build-tools 31.0.0
        • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • CocoaPods version 1.10.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 4.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.8+10-b944.6916264)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.2.1)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 61.2.4
        • Dart plugin version 212.5080.8
    
    [✓] VS Code (version 1.63.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.36.0
    
    [✓] Connected device (3 available)
        • Redmi K20 Pro (mobile) • 192.168.1.5:5555 • android-arm64  • Android 11 (API 30)
        • macOS (desktop)        • macos            • darwin-arm64   • macOS 12.1 21C52 darwin-arm
        • Chrome (web)           • chrome           • web-javascript • Google Chrome 99.0.4844.51
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    • No issues found!
    
  6. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Mar 15, 2022
  7. maheshj01 commented on Mar 16, 2022

    @maheshj01
    Member

    Please also check if this is related #81013 ?

  8. Fnalsk commented on Mar 16, 2022

    @Fnalsk
    Author

    This example isn't necessarily minimal in the sense of smallest number of lines of code. But the following was created by simply opening a new flutter project in Intellij and adding a TextField(),.

    Typing in that textfield and attempting to move the cursor on a physical galaxy s10 device results in the issue outlined above occurring.

    code sample
    import 'package:flutter/material.dart';
    
    void main() {
      runApp(const MyApp());
    }
    
    class MyApp extends StatelessWidget {
      const MyApp({Key? key}) : super(key: key);
    
      // This widget is the root of your application.
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Flutter Demo',
          theme: ThemeData(
            // This is the theme of your application.
            //
            // Try running your application with "flutter run". You'll see the
            // application has a blue toolbar. Then, without quitting the app, try
            // changing the primarySwatch below to Colors.green and then invoke
            // "hot reload" (press "r" in the console where you ran "flutter run",
            // or simply save your changes to "hot reload" in a Flutter IDE).
            // Notice that the counter didn't reset back to zero; the application
            // is not restarted.
            primarySwatch: Colors.blue,
          ),
          home: const MyHomePage(title: 'Flutter Demo Home Page'),
        );
      }
    }
    
    class MyHomePage extends StatefulWidget {
      const MyHomePage({Key? key, required this.title}) : super(key: key);
    
      // This widget is the home page of your application. It is stateful, meaning
      // that it has a State object (defined below) that contains fields that affect
      // how it looks.
    
      // This class is the configuration for the state. It holds the values (in this
      // case the title) provided by the parent (in this case the App widget) and
      // used by the build method of the State. Fields in a Widget subclass are
      // always marked "final".
    
      final String title;
    
      @override
      State<MyHomePage> createState() => _MyHomePageState();
    }
    
    class _MyHomePageState extends State<MyHomePage> {
      int _counter = 0;
    
      void _incrementCounter() {
        setState(() {
          // This call to setState tells the Flutter framework that something has
          // changed in this State, which causes it to rerun the build method below
          // so that the display can reflect the updated values. If we changed
          // _counter without calling setState(), then the build method would not be
          // called again, and so nothing would appear to happen.
          _counter++;
        });
      }
    
      @override
      Widget build(BuildContext context) {
        // This method is rerun every time setState is called, for instance as done
        // by the _incrementCounter method above.
        //
        // The Flutter framework has been optimized to make rerunning build methods
        // fast, so that you can just rebuild anything that needs updating rather
        // than having to individually change instances of widgets.
        return Scaffold(
          appBar: AppBar(
            // Here we take the value from the MyHomePage object that was created by
            // the App.build method, and use it to set our appbar title.
            title: Text(widget.title),
          ),
          body: Center(
            // Center is a layout widget. It takes a single child and positions it
            // in the middle of the parent.
            child: Column(
              // Column is also a layout widget. It takes a list of children and
              // arranges them vertically. By default, it sizes itself to fit its
              // children horizontally, and tries to be as tall as its parent.
              //
              // Invoke "debug painting" (press "p" in the console, choose the
              // "Toggle Debug Paint" action from the Flutter Inspector in Android
              // Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
              // to see the wireframe for each widget.
              //
              // Column has various properties to control how it sizes itself and
              // how it positions its children. Here we use mainAxisAlignment to
              // center the children vertically; the main axis here is the vertical
              // axis because Columns are vertical (the cross axis would be
              // horizontal).
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                const Text(
                  'You have pushed the button this many times:',
                ),
                TextField(),
                Text(
                  '$_counter',
                  style: Theme.of(context).textTheme.headline4,
                ),
              ],
            ),
          ),
          floatingActionButton: FloatingActionButton(
            onPressed: _incrementCounter,
            tooltip: 'Increment',
            child: const Icon(Icons.add),
          ), // This trailing comma makes auto-formatting nicer for build methods.
        );
      }
    }
    
  9. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Mar 16, 2022
  10. maheshj01 commented on Mar 16, 2022

    @maheshj01
    Member

    Thanks for the update @Fnalsk,

    There is a similar issue describing this case #98720, Please follow up there for further updates, Closing this issue as a duplicate. If you disagree feel free to write in the comments and we will reopen it.

    Thank you.

  11. added
    r: duplicateIssue is closed as a duplicate of an existing issue
    and removed
    in triagePresently being triaged by the triage team
    on Mar 16, 2022
  12. Fnalsk commented on Mar 17, 2022

    @Fnalsk
    Author

    That issue seems to only arise when there are two exclamation points at the end of the string? This one arises regardless of what the string is.

    The two are admittedly similar, but I wouldn't be confident in saying that fixing #98720 will also fix this.

  13. github-actions commented on Mar 31, 2022

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  14. locked as resolved and limited conversation to collaborators on Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    r: duplicateIssue is closed as a duplicate of an existing issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions