Repository navigation
[macOS] Setting composing range to TextRange.collapsed(0) breaks text input #64741
Description
Steps to Reproduce
- Clone https://github.com/memspace/zefyr.git
- Go to
packages/zefyr/exampleand run withflutter run -d macOS - Click on "Embedded in a form" example
- In the middle multiple field (that's ZefyrEditor) type in
abcand pressEnter
Expected results:
Enter should've added a new line
Actual results:
No new line appears.
While debugging I noticed that in my TextInputClient.updateEditingValue I get unexpected control characters when pressing Enter (13 (\r) instead of 10 (\n)), Delete (adds 8 code unit to the text) and arrow keys also modify the text itself instead of changing selection.
I scanned through the standard EditableTextState implementation and couldn't find anything that would indicate any issues in the way I set up input connection or handle updates.
When I use regular multiline TextField everything looks correct there and no special characters are present.
In the attached logs at the very end I have some printed statements for the raw text code units I receive from the platform side.
Logs
Logs were too big for a Github comment, so here is Gist:
https://gist.github.com/pulyaevskiy/5a1b28545994f0dae73185ba476c5929
$ flutter analyze
Analyzing example...
No issues found! (ran in 3.2s)
[✓] Flutter (Channel master, 1.22.0-2.0.pre.93, on Mac OS X 10.15.6 19G73, locale en-US)
• Flutter version 1.22.0-2.0.pre.93 at /Users/anatoly/Projects/flutter
• Framework revision f35a8b7470 (14 hours ago), 2020-08-26 21:33:03 -0700
• Engine revision 388193a67b
• Dart version 2.10.0 (build 2.10.0-62.0.dev)
[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /Users/anatoly/Library/Android/sdk
✗ Flutter requires Android SDK 29 and the Android BuildTools 28.0.3
To update using sdkmanager, run:
"/Users/anatoly/Library/Android/sdk/tools/bin/sdkmanager" "platforms;android-29" "build-tools;28.0.3"
or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions.
• All Android licenses accepted.
[✓] 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.9.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio
• Android Studio at /Applications/Android Studio 3.2 Preview.app/Contents
• Flutter plugin version 28.0.2
• Dart plugin version 181.5616
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
[✓] Android Studio (version 4.0)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 48.1.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
[✓] IntelliJ IDEA Community Edition (version 2018.1.6)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
• Flutter plugin version 26.0.2
• Dart plugin version 181.4892.1
[✓] VS Code (version 1.39.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.6.0
[✓] Connected device (3 available)
• macOS (desktop) • macos • darwin-x64 • Mac OS X 10.15.6 19G73
• Web Server (web) • web-server • web-javascript • Flutter Tools
• Chrome (web) • chrome • web-javascript • Google Chrome 84.0.4147.135
! Doctor found issues in 1 category.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
pulyaevskiy commentedon Aug 28, 2020
I found a fix for my issue - I had hardcoded initial value for
composingrange as0which was causing this weird behavior in the text input plugin. After setting it to-1everything works as expected.Even though my issue is resolved it still seems like something can be improved on the Flutter side of things so I'll keep this open. At least adding validation for
composingrange to prevent this from happening. I'm still not sure why would this have such a weird impact on the plugin's behavior.markusaksli-nc commentedon Aug 28, 2020
Hi @pulyaevskiy
Can you please provide a minimal complete reproducible code sample to demonstrate this issue? The example contains a lot of ancillary code from this third-party package.
Thank you
pulyaevskiy commentedon Aug 28, 2020
Sure, I was able to reproduce this with standard TextField.
Steps:
flutter createmain.dartwith the below snippetEnterandDeletekeys.Expected result:
Enteradds a new line.Deleteremoves a character.Actual result:
Enteradds a\randDeleteadds some other special character to thetextvalue.[-]Custom TextInputClient on macOS gets unexpected control characters in edited text[/-][+]Setting composing range to TextRange.collapsed(0) on macOS breaks text input[/+]TahaTesser commentedon Aug 31, 2020
Hi @pulyaevskiy
Thanks for providing a code sample and steps to reproduce the issue
I can reproduce the issue but there are no special characters when the
Deletekey is pressed, it just doesn't delete andEnterdoesn't add a new lineflutter doctor -v
flutter doctor -v
15 remaining items
eseidelGoogle commentedon Oct 19, 2021
@cbracken believes this is an uncommon flow and this should not be a blocker, but should be an easy-ish fix once we have time.
justinmc commentedon Oct 19, 2021
Unassigning myself while I look at #91859, but will come back to this once we've got that sorted.
a-wallen commentedon Aug 5, 2022
Looks like there are three different issues with reproducible steps
a-wallen commentedon Aug 5, 2022
a-wallen commentedon Aug 5, 2022
a-wallen commentedon Aug 6, 2022
[-]Setting composing range to TextRange.collapsed(0) on macOS breaks text input[/-][+][macOS] Setting composing range to TextRange.collapsed(0) breaks text input[/+]github-actions commentedon Sep 1, 2022
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.