flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
166.19k stars 27.49k forks source link

TextField's cursor cannot move in the middle of the word #114433

Closed siulun234 closed 3 weeks ago

siulun234 commented 2 years ago

When I am trying to insert some words in the middle of the sentence in TextFormField and TextField, it will select a range of words and I am unable to move the cursor to the correct position to insert some word in the middle.

To fix this issue, I have to add a space at the end of the sentence and remove it immediately, then every things get work. But the issue will come again after I typed some words.

This issue is happened in web (ios), ios and android.

https://user-images.githubusercontent.com/4901887/199273166-69162015-fd4a-416e-b217-61a00ff2e5d4.mov

Steps to Reproduce

  1. Execute flutter run on the code sample
  2. Type a sentence into the TextField or TextFormField
  3. Try to insert some words in the middle of the sentence

Expected results: A cursor can move between the word, and able to insert some word into it

Actual results: selected a rang of word when I tap the word, and I am unable to move the cursor to insert text

Code sample ``` @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text("Flutter Demo Home Page"), centerTitle: true, ), body: const TextField(), ); } ```
flutter doctor -v ``` [✓] Flutter (Channel stable, 3.3.6, on macOS 12.2.1 21D62 darwin-x64, locale en-GB) • Flutter version 3.3.6 on channel stable at /Users/samuelma/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 6928314d50 (7 days ago), 2022-10-25 16:34:41 -0400 • Engine revision 3ad69d7be3 • Dart version 2.18.2 • DevTools version 2.15.0 [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) • Android SDK at /Users/samuelma/Library/Android/sdk • Platform android-33, build-tools 31.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 13.3) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 13E113 • CocoaPods version 1.11.3 [✓] 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-7281165) [✓] VS Code (version 1.72.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.50.0 [✓] Connected device (3 available) • SM N9600 (mobile) • 26dc252164217ece • android-arm64 • Android 10 (API 29) • macOS (desktop) • macos • darwin-x64 • macOS 12.2.1 21D62 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 107.0.5304.87 [✓] HTTP Host Availability • All required HTTP hosts are available • No issues found! ```
danagbemava-nc commented 2 years ago

Hi @siulun234, I attempted to reproduce the issue but I could not. Everything worked just fine on my end.

See the recording below. Is there something I missed?

PS: I tested this on the platforms you mentioned, but it was the same for me throughout.

recording https://user-images.githubusercontent.com/88313112/199665489-78df9dc8-b956-4a22-8412-b1720e2eae75.mp4
siulun234 commented 2 years ago

Is it because of the version of my android device? My testing device is Android 10 (physical device).

danagbemava-nc commented 2 years ago

Hi @siulun234, what device are you testing this on?

If you test this in an android emulator, does it work for you or do you still experience the bug?

Can you also check on the latest version of stable/master to see if it makes any difference?

siulun234 commented 2 years ago

Hi @danagbemava-nc, I am using Samsung Galaxy Note 9 (Android 10) for my testing.

I had just test the app in the android emulator (Android 10 & 11), every things is fine. But I will get this bug when I am installed the same program in my physical device. Any things will get this happen?

I am using the latest version stable 3.3.6 for my testing.

danagbemava-nc commented 2 years ago

Hi @siulun234, you mentioned that this issue was on iOS as well. What iOS device did you test this on?

The latest stable version is 3.3.7. You can also try on the master channel to see if it reproduces for you.

Thank you

sajadisam commented 1 year ago

Any updates on this issue. Facing the same problems on my Samsung Galaxy S9 android 10. I'm on the stable channel version 3.3.9.

danagbemava-nc commented 1 year ago

Hi @renewablezip01, do you experience this issue on only Samsung devices?

sajadisam commented 1 year ago

@danagbemava-nc I've tested on Huawei p20 and it seemed to work fine, however the 'drag pin' is buggy in that it stops after roughly 1 second of dragging.

I'm having this tap selection issue with my Samsung phone, not sure if all Samsung devices is affected by this - but there was previous commenter on this topic who had a Samsung device (Samsung Galaxy Note 9) which experienced the same issue. The TextField/TextFormField works just fine on an emulator but it is buggy on an actual device, hence why you might be having issues reproducing the bug.

I tested on other flutter production released apps on play store, and it is the exact same issue, also created a new flutter project and added just a TextField, same issue. I tried to change to 'beta' and 'master' channel, same issue.

Furthermore, both TextField and TextFormField is affected by this.

danagbemava-nc commented 1 year ago

however the 'drag pin' is buggy in that it stops after roughly 1 second of dragging.

Kindly file a new issue for this so that it can be addressed.

The TextField/TextFormField works just fine on an emulator but it is buggy on an actual device, hence why you might be having issues reproducing the bug.

I tested on my physical device, a Poco X3 NFC as commented in https://github.com/flutter/flutter/issues/114433#issuecomment-1301723902

Furthermore, both TextField and TextFormField is affected by this.

TextFormField technically is only a Form wrapper around TextField.

@renewablezip01 for reference sake, can you share the flutter doctor -v output of master and beta you tried this one?

sajadisam commented 1 year ago

@danagbemava-nc Apologies for the late reply.

I tested on my physical device, a Poco X3 NFC as commented in https://github.com/flutter/flutter/issues/114433#issuecomment-1301723902

The device you've tested on seems to work fine, on other devices such as mine, it is different. As mentioned earlier the problem is when single-tapping it causes selection.

for reference sake, can you share the flutter doctor -v output of master and beta you tried this one?

Here is the information that you've requested:

stable 3.3.9 ``` [✓] Flutter (Channel stable, 3.3.9, on Manjaro Linux 5.15.76-1-MANJARO, locale en_US.UTF-8) • Flutter version 3.3.9 on channel stable at /home/---/snap/flutter/common/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision b8f7f1f986 (10 days ago), 2022-11-23 06:43:51 +0900 • Engine revision 8f2221fbef • Dart version 2.18.5 • DevTools version 2.15.0 [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) • Android SDK at /home/---/Android/Sdk • Platform android-33, build-tools 33.0.0 • ANDROID_HOME = /home/---/Android/Sdk • Java binary at: /var/lib/snapd/snap/android-studio/125/android-studio/jre/bin/java • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866) • All Android licenses accepted. [✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome) ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable. [✓] Linux toolchain - develop for Linux desktop • clang version 10.0.0-4ubuntu1 • cmake version 3.16.3 • ninja version 1.10.0 • pkg-config version 0.29.1 [✓] Android Studio (version 2021.3) • Android Studio at /var/lib/snapd/snap/android-studio/125/android-studio • 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.13+0-b1751.21-8125866) [✓] Connected device (2 available) • sdk gphone x86 64 arm64 (mobile) • emulator-5554 • android-x64 • Android 11 (API 30) (emulator) • Linux (desktop) • linux • linux-x64 • Manjaro Linux 5.15.76-1-MANJARO [✓] HTTP Host Availability • All required HTTP hosts are available ! Doctor found issues in 1 category. ```
beta, 3.6.0-0.1.pre ``` [✓] Flutter (Channel beta, 3.6.0-0.1.pre, on Manjaro Linux 5.15.76-1-MANJARO, locale en_US.UTF-8) • Flutter version 3.6.0-0.1.pre on channel beta at /home/---/snap/flutter/common/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 75927305ff (2 weeks ago), 2022-11-17 05:52:50 +0530 • Engine revision b754eabc98 • Dart version 2.19.0 (build 2.19.0-374.1.beta) • DevTools version 2.19.0 [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) • Android SDK at /home/---/Android/Sdk • Platform android-33, build-tools 33.0.0 • ANDROID_HOME = /home/---/Android/Sdk • Java binary at: /var/lib/snapd/snap/android-studio/125/android-studio/jre/bin/java • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866) • All Android licenses accepted. [✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome) ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable. [✓] Linux toolchain - develop for Linux desktop • clang version 10.0.0-4ubuntu1 • cmake version 3.16.3 • ninja version 1.10.0 • pkg-config version 0.29.1 [✓] Android Studio (version 2021.3) • Android Studio at /var/lib/snapd/snap/android-studio/125/android-studio • 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.13+0-b1751.21-8125866) [✓] Connected device (2 available) • sdk gphone x86 64 arm64 (mobile) • emulator-5554 • android-x64 • Android 11 (API 30) (emulator) • Linux (desktop) • linux • linux-x64 • Manjaro Linux 5.15.76-1-MANJARO [✓] HTTP Host Availability • All required HTTP hosts are available ! Doctor found issues in 1 category. ```
master 3.7.0-2.0pre.9 ``` [✓] Flutter (Channel master, 3.7.0-2.0.pre.9, on Manjaro Linux 5.15.76-1-MANJARO, locale en_US.UTF-8) • Flutter version 3.7.0-2.0.pre.9 on channel master at /home/---/snap/flutter/common/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision ce94230281 (13 hours ago), 2022-12-01 19:13:07 -0800 • Engine revision 025aefc7af • Dart version 2.19.0 (build 2.19.0-444.0.dev) • DevTools version 2.20.0 [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) • Android SDK at /home/---/Android/Sdk • Platform android-33, build-tools 33.0.0 • ANDROID_HOME = /home/---/Android/Sdk • Java binary at: /var/lib/snapd/snap/android-studio/125/android-studio/jre/bin/java • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866) • All Android licenses accepted. [✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome) ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable. [✓] Linux toolchain - develop for Linux desktop • clang version 10.0.0-4ubuntu1 • cmake version 3.16.3 • ninja version 1.10.0 • pkg-config version 0.29.1 [✓] Android Studio (version 2021.3) • Android Studio at /var/lib/snapd/snap/android-studio/125/android-studio • 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.13+0-b1751.21-8125866) [✓] Connected device (2 available) • sdk gphone x86 64 arm64 (mobile) • emulator-5554 • android-x64 • Android 11 (API 30) (emulator) • Linux (desktop) • linux • linux-x64 • Manjaro Linux 5.15.76-1-MANJARO [✓] HTTP Host Availability • All required HTTP hosts are available ! Doctor found issues in 1 category. ```
danagbemava-nc commented 1 year ago

@renewablezip01, thanks for the info.

Labeling this for further investigation as I cannot reproduce this locally.

This seems to be affecting only Samsung devices at the moment.

sajadisam commented 1 year ago

Upon further inspection and looking into the https://github.com/flutter/flutter/issues/98720 issue, it appears that the phone setting "cursor control" is causing this issue. Disabling it would fix the issue but that is not a viable fix as we ought not to enforce app users to disable such setting for a fix.

darshankawar commented 1 month ago

Upon further inspection and looking into the #98720 issue, it appears that the phone setting "cursor control" is causing this issue.

This is correct. I tried this issue on S10+ device (Android 12) and was able to replicate the reported behavior, but upon checking the settings, I had cursor control enabled. Disabling it didn't replicate the reported behavior.

Disabling it would fix the issue but that is not a viable fix as we ought not to enforce app users to disable such setting for a fix.

I am not sure if Flutter would have any control over device settings so I am not sure if there would be a fix for it in the framework.

@siulun234 Please check this and try again at your end by disabling cursor control feature (assuming you had that enabled when you found this issue).

github-actions[bot] commented 3 weeks ago

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. If you find this problem please file a new issue with the same description, what happens, logs and the output of 'flutter doctor -v'. All system setups can be slightly different so it's always better to open new issues and reference the related ones. Thanks for your contribution.

github-actions[bot] commented 1 week ago

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.