Skip to content

Spaces at the end of a center aligned textfield don't show up #25312

Closed

Description

@mploigt

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)

Activity

  1. added
    a: text inputEntering text in a text field or keyboard related problems
    frameworkflutter/packages/flutter repository. See also f: labels.
    engineflutter/engine related. See also e: labels.
    on Dec 13, 2018
  2. added this to the milestone on Dec 13, 2018
  3. HansMuller commented on Dec 13, 2018

    @HansMuller
    Contributor
  4. GaryQian commented on Dec 13, 2018

    @GaryQian
    Contributor

    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.

  5. GaryQian commented on Dec 13, 2018

    @GaryQian
    Contributor

    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().

  6. mploigt commented on Dec 14, 2018

    @mploigt
    Author

    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.

  7. Kartik1607 commented on Dec 18, 2018

    @Kartik1607
    Contributor

    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.

  8. self-assigned this
    on Dec 18, 2018
  9. GaryQian commented on Dec 18, 2018

    @GaryQian
    Contributor

    This all sounds very reasonable. I will add the additional tracking info to LibTxt to enable this behavior.

  10. GaryQian commented on Dec 18, 2018

    @GaryQian
    Contributor

    I am unable to reproduce your first and last bullet point. I am not seeing the behavior described by

    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)

    and

    If you try to position the cursor at the beginning of the text, the curser will jump to the middle.

    Can you ensure that this still occurs on master?

  11. changed the title [-]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[/+] on Jan 4, 2019
  12. goderbauer commented on Jan 4, 2019

    @goderbauer
    Member

    I also cannot reproduce 1 & 3. Let's repurpose this bug to cover the spaces issue.

  13. GaryQian commented on Jan 16, 2019

    @GaryQian
    Contributor

    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

  14. GaryQian commented on Feb 12, 2019

    @GaryQian
    Contributor

    The space tracking is added in flutter-team-archive/engine#7791.

  15. canewsin commented on Apr 29, 2019

    @canewsin

    The Problem Still Exists How to solve this

  16. GaryQian commented on Apr 29, 2019

    @GaryQian
    Contributor

    Try the beta, dev, or master channels. The fix may not have made it into the stable channel yet.

  17. github-actions commented on Aug 14, 2021

    @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.

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

Metadata

Metadata

Assignees

Labels

a: text inputEntering text in a text field or keyboard related problemsengineflutter/engine related. See also e: labels.frameworkflutter/packages/flutter repository. See also f: labels.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions