Repository navigation
TextEditingController is not updating cursor position #65547
Copy link
Copy link
Closed as not planned
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsc: regressionIt was better in the past than it is nowIt was better in the past than it is nowfound in release: 3.3Found to occur in 3.3Found to occur in 3.3found in release: 3.6Found to occur in 3.6Found to occur in 3.6frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagesteam-text-inputOwned by Text Input teamOwned by Text Input teamtriaged-text-inputTriaged by Text Input teamTriaged by Text Input team
Description
After I updated to Flutter 1.20.3 I am having a problem with the TextEditingController. On iOS it still works as before but, on Android, the controller is not notifying listeners when value is empty. It should notify when I had some value and erased it as it does on iOS.
flutter doctor -v
[✓] Flutter (Channel stable, 1.20.3, on Mac OS X 10.15.6 19G73, locale pt)
• Flutter version 1.20.3 at /Users/leonardosilva/development/flutter/flutter
• Framework revision 216dee60c0 (9 days ago), 2020-09-01 12:24:47 -0700
• Engine revision d1bc06f032
• Dart version 2.9.2
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /Users/leonardosilva/Library/Android/sdk
• Platform android-29, build-tools 29.0.3
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_242-release-1644-b3-6222593)
! Some Android licenses not accepted. To resolve this, run: flutter doctor
--android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 11.6)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.6, Build version 11E708
• CocoaPods version 1.8.4
[✓] Android Studio (version 4.0)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 49.0.2
• Dart plugin version 193.7547
• Java version OpenJDK Runtime Environment (build
1.8.0_242-release-1644-b3-6222593)
[✓] VS Code (version 1.48.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.14.1
[✓] Connected device (1 available)
• Mi A2 (mobile) • d73165 • android-arm64 • Android 10 (API 29)
! Doctor found issues in 1 category.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsc: regressionIt was better in the past than it is nowIt was better in the past than it is nowfound in release: 3.3Found to occur in 3.3Found to occur in 3.3found in release: 3.6Found to occur in 3.6Found to occur in 3.6frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagesteam-text-inputOwned by Text Input teamOwned by Text Input teamtriaged-text-inputTriaged by Text Input teamTriaged by Text Input team
Activity
xu-baolin commentedon Sep 11, 2020
@lslv1243 Hi
I cannot reproduce the problem in the version you mentioned and the latest version, please provide a minimal complete reproducible code sample that shows the issue.
Sample Code
flutter doctor -v
lslv1243 commentedon Sep 11, 2020
@xu-baolin Hi
I was using it actually only as a hidden input for my custom styled input and did not look at the exact input behavior. This difference has started in the newer version but is not as simple as I described, what is happening is that the cursor is behaving differently on Android than it does on iOS and it did on Android.
On Android before and iOS now, after erasing, the cursor stays to the right-hand side of the number.
On Android now, after erasing, the cursor stays to the left-hand side of the number.
This new behavior made my code break, because if the cursor is to the left-right side of the text and I try to erase, nothing happens, that is why I described the way I did.
I edited your code to show this behavior.
Sample code
pedromassangocode commentedon Sep 11, 2020
Hi @lslv1243
Does the code bellow reproduce the issue you are facing?
Code
lslv1243 commentedon Sep 11, 2020
No, it does not. As I described afterwards, it has to do with the cursor #65547 (comment). It is not as simple as I described initially.
pedromassangocode commentedon Sep 15, 2020
I noticed that we have a breaking change here.
Testing on iOS with Flutter 1.17.5, the text field does updates the position of the indicator automatically after clearing the text field but it does not while testing with Flutter 1.20.3.
This can be worked around by updating the selection while changing the text in the controller:
Testing with Flutter 1.17.5
Testing with Flutter 1.20.3
flutter doctor -v
10 remaining items
justinmc commentedon Oct 24, 2024
@LongCatIsLooong to check if this is still reproducible.
LongCatIsLooong commentedon Oct 29, 2024
The selection is reset if you use the
textsetter:See https://main-api.flutter.dev/flutter/widgets/TextEditingController/text.html
I think we should deprecate this setter or mark it
visibleForTesting, as it has been a major source of confusion.Mark `TextEditingController.text` setter as `@visibleForTesting`
github-actions commentedon Nov 12, 2024
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 -vand a minimal reproduction of the issue.