Skip to content

TextField cursor stands in a wrong position while using persian words #120604

Closed

Description

@mhbdev

That is really annoying. TextField(s) are ruining all my days and nights. This is not the first issue I am encountering since I'm using flutter but I hope this would be the last.

Steps to reproduce this problem are so easy. create a flutter application. make sure you are using flutter 3.7.3 (the latest version on stable channel). use a simple TextField widget. Type a simple word in persian (or Arabic) with no space in the end. (e.g. سلام در حال تست). After typing that, click on the last character. The thing is cursor is not in the right position which you can see in the picture I am sharing.

image

Activity

  1. moffatman commented on Feb 13, 2023

    @moffatman
    Contributor

    Can you try out the master channel and see if it's fixed there? I've made an improvement for clicking on the last character in right-to-left text.

  2. darshankawar commented on Feb 14, 2023

    @darshankawar
    Member

    @mhbdev
    flutter channel master
    flutter upgrade and try to run your scenario again.

  3. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Feb 14, 2023
  4. mhbdev commented on Feb 14, 2023

    @mhbdev
    ContributorAuthor

    @darshankawar @moffatman
    I tried master channel and the problem still exists.

  5. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Feb 14, 2023
  6. moffatman commented on Feb 14, 2023

    @moffatman
    Contributor

    @mhbdev What's the exact revision (flutter doctor -v)?

  7. mhbdev commented on Feb 15, 2023

    @mhbdev
    ContributorAuthor

    Here you are @moffatman

    [√] Flutter (Channel master, 3.8.0-12.0.pre.52, on Microsoft Windows [Version 10.0.19045.2486], locale en-US)
    • Flutter version 3.8.0-12.0.pre.52 on channel master at C:\FlutterSdk\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 17b4c70 (14 hours ago), 2023-02-14 10:07:02 +0000
    • Engine revision cbb7fc0
    • Dart version 3.0.0 (build 3.0.0-233.0.dev)
    • DevTools version 2.21.1
    • Pub download mirror https://pub.flutter-io.cn

  8. moffatman commented on Feb 15, 2023

    @moffatman
    Contributor

    What operating system do you see the problem on? I tried with the string you posted "سلام در حال تست", and it looks correct for me on iOS using latest master channel.

  9. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Feb 15, 2023
  10. mhbdev commented on Feb 15, 2023

    @mhbdev
    ContributorAuthor

    What operating system do you see the problem on? I tried with the string you posted "سلام در حال تست", and it looks correct for me on iOS using latest master channel.

    I am on Windows tried this example on chrome web.

  11. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Feb 15, 2023
  12. moffatman commented on Feb 15, 2023

    @moffatman
    Contributor

    Ah, on Web, I think we need to wait for a new CanvasKit to release to include the fix.

    Do you know the next expected release? @jason-simmons

  13. darshankawar commented on Feb 16, 2023

    @darshankawar
    Member

    I was able to verify and replicate the reported behavior. This occurs on web using canvaskit renderer on latest master and stable versions:

    120604.mov

    With html renderer, the cursor goes properly to the position:

    Screenshot 2023-02-16 at 11 25 37 AM

    This only seems to be happening on web platform, as on desktop, it works as expected.

    A similar / related issue: #81013

    void main() => runApp(MyApp());
    
    class MyApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return MaterialApp(home: Scaffold
          (body: Center(child: TextFormField(
          textDirection: TextDirection.rtl,
          //  maxLines: 10,
        ))));
      }
    }
    
    stable, master flutter doctor -v
    [!] Flutter (Channel stable, 3.7.3, on macOS 12.2.1 21D62 darwin-x64, locale
        en-GB)
        • Flutter version 3.7.3 on channel stable at
          /Users/dhs/documents/fluttersdk/flutter
        ! Warning: `flutter` on your path resolves to
          /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside
          your current Flutter SDK checkout at
          /Users/dhs/documents/fluttersdk/flutter. Consider adding
          /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path.
        ! Warning: `dart` on your path resolves to
          /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your
          current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter.
          Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front
          of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 9944297138 (4 days ago), 2023-02-08 15:46:04 -0800
        • Engine revision 248290d6d5
        • Dart version 2.19.2
        • DevTools version 2.20.1
        • If those were intentional, you can disregard the above warnings; however
          it is recommended to use "git" directly to perform update checks and
          upgrades.
    
    [!] Xcode - develop for iOS and macOS (Xcode 12.3)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        ! Flutter recommends a minimum Xcode version of 13.
          Download the latest version or update via the Mac App Store.
        • CocoaPods version 1.11.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] VS Code (version 1.62.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.21.0
    
    [✓] Connected device (5 available)
        • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
        • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
          ios            • iOS 14.4.1 18D61
        • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729     •
          ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
        • macOS (desktop)            • macos                                    •
          darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
        • Chrome (web)               • chrome                                   •
          web-javascript • Google Chrome 98.0.4758.80
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    ! Doctor found issues in 1 category.
    
    [!] Flutter (Channel master, 3.8.0-13.0.pre.52, on macOS 12.2.1 21D62
        darwin-x64, locale en-GB)
        • Flutter version 3.8.0-13.0.pre.52 on channel master at
          /Users/dhs/documents/fluttersdk/flutter
        ! Warning: `flutter` on your path resolves to
          /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside
          your current Flutter SDK checkout at
          /Users/dhs/documents/fluttersdk/flutter. Consider adding
          /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path.
        ! Warning: `dart` on your path resolves to
          /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your
          current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter.
          Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front
          of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision cc473e4f19 (73 minutes ago), 2023-02-15 22:51:19 -0500
        • Engine revision 3fc40ca5be
        • Dart version 3.0.0 (build 3.0.0-241.0.dev)
        • DevTools version 2.21.1
        • If those were intentional, you can disregard the above warnings; however
          it is recommended to use "git" directly to perform update checks and
          upgrades.
          
    [!] Xcode - develop for iOS and macOS (Xcode 12.3)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        ! Flutter recommends a minimum Xcode version of 13.
          Download the latest version or update via the Mac App Store.
        • CocoaPods version 1.11.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] VS Code (version 1.62.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.21.0
    
    [✓] Connected device (5 available)
        • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
        • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
          ios            • iOS 14.4.1 18D61
        • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729     •
          ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
        • macOS (desktop)            • macos                                    •
          darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
        • Chrome (web)               • chrome                                   •
          web-javascript • Google Chrome 98.0.4758.80
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    ! Doctor found issues in 1 category.
    
    
    
    
  14. 16 remaining items

  15. mhbdev commented on Mar 25, 2023

    @mhbdev
    ContributorAuthor

    I am facing this issue on both platforms. Android and Web.

  16. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Mar 25, 2023
  17. added
    P2Important issues not at the top of the work list
    on Mar 30, 2023
  18. ammarqusailah commented on Apr 15, 2023

    @ammarqusailah

    This solution worked for me with Android and Windows

    controller.addListener(() {
          if (controller != null) {
            if (controller.selection ==
                TextSelection.fromPosition(
                  TextPosition(
                    offset: controller.text.length - 1,
                  ),
                )) {
              controller.selection = TextSelection.fromPosition(
                TextPosition(
                  offset: controller.text.length,
                ),
              );
            }
          }
        });
  19. abdullahqasemi commented on Apr 16, 2023

    @abdullahqasemi

    This solution worked for me with Android and Windows

    controller.addListener(() {
          if (controller != null) {
            if (controller.selection ==
                TextSelection.fromPosition(
                  TextPosition(
                    offset: controller.text.length - 1,
                  ),
                )) {
              controller.selection = TextSelection.fromPosition(
                TextPosition(
                  offset: controller.text.length,
                ),
              );
            }
          }
        });

    this worked for me
    Thanks

  20. LongCatIsLooong commented on Oct 26, 2023

    @LongCatIsLooong
    Contributor

    Tried with canvaskit renderer and on linux. The issue doesn't seem reproducible on the master branch. Closing.

  21. added
    r: fixedIssue is closed as already fixed in a newer version
    on Oct 27, 2023
  22. github-actions commented on Nov 10, 2023

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

  23. locked as resolved and limited conversation to collaborators on Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: internationalizationSupporting other languages or locales. (aka i18n)a: text inputEntering text in a text field or keyboard related problemsdependency: skiaSkia team may need to help use: web_canvaskitCanvasKit (a.k.a. Skia-on-WebGL) rendering backend for Webengineflutter/engine related. See also e: labels.found in release: 3.7Found to occur in 3.7found in release: 3.8Found to occur in 3.8has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyplatform-webWeb applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-engineOwned by Engine teamtriaged-engineTriaged by Engine team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions