Repository navigation
Spaces at the end of a center aligned textfield don't show up #25312
Copy link
Copy link
Closed
Labels
a: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.
Description
This problem is presumably fixed by #24456 but it is not.
- If you first tap into the field, the cursor is in the middle (If testing in the simulator, try to click at the beginning of the field)
- If you enter spaces at the end of the text, they will not show up.
- If you try to position the cursor at the beginning of the text, the curser will jump to the middle.
https://gist.github.com/mploigt/5e3df23641f7f695f67fc7041fc50609
Analyzing center_aligned_text_field...
No issues found! (ran in 2.4s)
[✓] Flutter (Channel master, v1.1.1-pre.8, on Mac OS X 10.14.1 18B75, locale en-DE)
• Flutter version 1.1.1-pre.8 at /Users/maik/Projects/flutter
• Framework revision 2994d3562a (22 hours ago), 2018-12-12 10:56:54 +0000
• Engine revision abb1d3a6c0
• Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
• Android SDK at /Users/maik/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-27, build-tools 27.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_152-release-1136-b06)
• All Android licenses accepted.
[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.1, Build version 10B61
• ios-deploy 1.9.4
• CocoaPods version 1.5.3
[✓] Android Studio
• Android Studio at /Applications/Android Studio 3.4 Preview.app/Contents
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
[✓] Android Studio
• Android Studio at /Applications/Android Studio 3.3 Preview.app/Contents
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
[✓] Android Studio (version 3.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 31.1.1
• Dart plugin version 181.5656
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
[✓] VS Code (version 1.28.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 2.19.0
[✓] Connected device (2 available)
• iPhone XS • F80C82FC-9069-430F-805A-062E112A1B1A • ios • iOS 12.1 (simulator)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
a: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.
Activity
HansMuller commentedon Dec 13, 2018
cc @GaryQian
GaryQian commentedon Dec 13, 2018
The bug reported in #24456 was indeed fixed. The fix that was landed specifically fixes the caret jumping to the middle when a space is typed at the end, and should not resolve other behaviors. The caret behavior at the beginning of text is actually due to a separate issue, and will likely require a separate fix to resolve due to different root causes (I will link them whenever I find the related issues). The beginning-of-text caret weirdness is not unique to centered text, but is much more apparent in this case.
The behavior where spaces do not appear at the end of text is indeed expected. To perform center alignment, trailing whitespace does not contribute line width. I agree that this behavior is not well indicated to the user. Maybe we could show the caret moving forwards but still layout according to the current policy. That way, it is apparent that the spaces are not just disappearing but rather simply not impacting the centering.
GaryQian commentedon Dec 13, 2018
To fix the spaces not showing up at the end, we will need to track additional information in LibTxt and make it accessible via
Paragraph::GetRectsForRange().mploigt commentedon Dec 14, 2018
I think it's important to show the user that spaces he enters actually are added to the text. I would not mind that the visible text would then appear not to be centered during entering the spaces. If the user finished editing you still could trim the text to center it again. But that should be up to the user/programmer.
On a centered textfield I would expect the whole string (including spaces) to be centered.
Kartik1607 commentedon Dec 18, 2018
Agree with @mploigt The spaces entered by user must always be visible. Try adding 5-10 spaces to a textfield and then enter a character, and the whole text field would now jump. If spaces were contributing to width, it would feel fluid to user.
GaryQian commentedon Dec 18, 2018
This all sounds very reasonable. I will add the additional tracking info to LibTxt to enable this behavior.
GaryQian commentedon Dec 18, 2018
I am unable to reproduce your first and last bullet point. I am not seeing the behavior described by
and
Can you ensure that this still occurs on master?
[-]Center aligned TextField shows caret in the middle when it gets focus[/-][+]Spaces at the end of a center aligned textfield don't show up[/+]goderbauer commentedon Jan 4, 2019
I also cannot reproduce 1 & 3. Let's repurpose this bug to cover the spaces issue.
GaryQian commentedon Jan 16, 2019
I have opened a separate issue to track the issue regarding spaces appearing on centered text (#2), as it is a separate issue with work required in libtxt and implementation-wise not directly related to the original bug. #26658
GaryQian commentedon Feb 12, 2019
The space tracking is added in flutter-team-archive/engine#7791.
canewsin commentedon Apr 29, 2019
The Problem Still Exists How to solve this
GaryQian commentedon Apr 29, 2019
Try the beta, dev, or master channels. The fix may not have made it into the stable channel yet.
github-actions commentedon Aug 14, 2021
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.