Skip to content

Korean characters are displayed abnormally in TextField when moved cursor. #29341

Closed
flutter-team-archive/engine
#12432

Description

@0psmith

Steps to reproduce

  1. Input some Korean Characters into the TextField
    안녕하세요|

  2. Move cursor to middle of characters
    안녕|하세요

  3. input some characters or numbers whatever
    안녕5|하세요

  4. boom
    안녕하세요5|하세요

Check This

  1. Video
    https://serviceapi.nmv.naver.com/flash/convertIframeTag.nhn?vid=98B4DFE49D13BFBEED4D444D7EAECFCF789A&outKey=V124950047e787575d0585747baa0b9e1633eb84b1000f944d5ac5747baa0b9e1633e&width=544&height=306

  2. TextField Code

TextEditingController _textEditingController = TextEditingController();

return Container(
    color: Colors.transparent,
    padding: EdgeInsets.all(10.0),
    child: Card(
        color: Colors.transparent,
        elevation: 8,
        child: ClipRRect(
            borderRadius: BorderRadius.all(Radius.circular(16.0)),
            child: Container(
              height: 50.0,
              padding: EdgeInsets.symmetric(horizontal: 16.0),
              color: Theme.of(context).accentColor,
              child: TextField(
                decoration: InputDecoration(icon: Icon(Icons.search), border: InputBorder.none, hintStyle: TextStyle(fontSize: 18), hintText: getHintText()),
                textInputAction: TextInputAction.search,
                cursorColor: Colors.black,
                style: TextStyle(fontSize: 18),
                controller: _textEditingController,
                onSubmitted: (text) => handleSearch(context, searched_keyword, text, search_module_srl),
              ),
            ))),
    );

Logs

flutter analyze

There is no `flutter analyze` Error.

flutter doctor -v

[√] Flutter (Channel stable, v1.0.0, on Microsoft Windows [Version 10.0.17134.648], locale ko-KR)
    • Flutter version 1.0.0 at C:\flutter
    • Framework revision 5391447fae (3 months ago), 2018-11-29 19:41:26 -0800
    • Engine revision 7375a0f414
    • Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)

[√] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    • Android SDK at C:\Users\admin\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
    • All Android licenses accepted.

[√] Android Studio (version 3.1)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 29.0.1
    • Dart plugin version 173.4700
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)

[!] VS Code, 64-bit edition (version 1.27.2)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (1 available)
    • SM G973N • R39M20E00AJ • android-arm64 • Android 9 (API 28)

! Doctor found issues in 1 category.

This problem only occurs on Android only .. iOS was fine.

Activity

  1. added
    a: text inputEntering text in a text field or keyboard related problems
    p: material_uimaterial_ui package in flutter/packages
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Jun 21, 2019
  2. HansMuller commented on Jun 21, 2019

    @HansMuller
    Contributor
  3. timsneath commented on Sep 3, 2019

    @timsneath

    I am not myself able to reproduce this on the latest Flutter master:
    image

    Could you try upgrading with flutter upgrade and try again on a more recent build? This may have been fixed since it was reported...

    My minimal repro attempt is here: https://gist.github.com/timsneath/284c320678435bd29ae6e7f7aa73d1ce

  4. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Sep 3, 2019
  5. timsneath commented on Sep 5, 2019

    @timsneath

    This bug reproduces on a Samsung Galaxy 9 with the Samsung keyboard, running v1.7.8 from the stable channel. It may have the same cause as #31512. It does not reproduce with the Gboard keyboard. The bug is blocking a Korean company from shipping a flagship Flutter app, and so they are seeking a fix urgently.

  6. 17 remaining items

  7. justinmc commented on Sep 20, 2019

    @justinmc
    Contributor

    I filed a bug on Android as I continue to investigate this: https://b.corp.google.com/issues/141367011

  8. justinmc commented on Sep 23, 2019

    @justinmc
    Contributor

    I'm making some progress but not quite there yet. @mklim came up with a fix that worked on native Android, but it didn't work when I tried copying it into Flutter. I found that when I extended BaseInputConnection like Flutter does, then the solution didn't work in native Android either. My conclusion is that Flutter's BaseInputConnection subclass is somehow causing this problem.

    I found that I can make native Android work by adding these three methods from BaseInputClass to the subclass:

    public class InputConnectionAdapter extends BaseInputConnection {
    
        ...
    
        @Override
        public boolean beginBatchEdit() {
            synchronized(this) {
                if (mBatchEditNesting >= 0) {
                    // Can't be called in Flutter because there is no mTextView.
                    mTextView.beginBatchEdit();
                    mBatchEditNesting++;
                    return true;
                }
            }
            return false;
        }
    
        @Override
        public boolean endBatchEdit() {
            synchronized(this) {
                if (mBatchEditNesting > 0) {
                    // Can't be called in Flutter because there is no mTextView.
                    mTextView.endBatchEdit();
                    mBatchEditNesting--;
                    return true;
                }
            }
            return false;
        }
    
        @Override
        public ExtractedText getExtractedText(ExtractedTextRequest request, int flags) {
            if (mTextView != null) {
                ExtractedText et = new ExtractedText();
                // Can't be called in Flutter because there is no mTextView.
                if (mTextView.extractText(request, et)) {
                    if ((flags&GET_EXTRACTED_TEXT_MONITOR) != 0) {
                        // Can't be called in Flutter or my Android app because setExtracting is hidden
                        // or something like that. However, that doesn't seem to matter!  Still works.
                        //mTextView.setExtracting(request);
                    }
                    return et;
                }
            }
            return null;
        }
    
        ...
    
    }

    As pointed out in the comments in the code block, there are three vital calls here that are not able to be made in Flutter due to Flutter not having an instance of TextView. Removing any of these causes the solution to not work.

    From here, maybe I can look into the source code of these three calls and see if I can figure out what exactly is making this work, and if we can somehow do the same in Flutter.

  9. mklim commented on Sep 24, 2019

    @mklim
    Contributor

    I have one potential workaround up at mklim/engine@1134c9e7c557586d0a21a1b758c480532cbd12db. It still needs tests before I open it as a PR but I think the basic approach will unblock this. It's extremely heavy handed, but I think it is feasible. I'm restarting the IMM instead of finishComposingText(). From what I could tell since we're using updateSelection we need a full restart.

  10. self-assigned this
    on Sep 24, 2019
  11. Kiboom commented on Sep 25, 2019

    @Kiboom

    We’re building a Q&A service using Flutter, which contains TextFields for the question.
    Users tend to type lengthy text on it, so there's a high chance that they move cursor and insert some characters.
    But like it's been discussed in the thread, the same issue reproduces in our TextFields on Samsung devices with Samsung Keyboard.
    Since writing action is the key feature of our app, it's very critical issue that blocks us from shipping our flagship app.

    It's a good to know that potential workaround has been found, though :)
    Due to the time-sensitive schedule, we hope this issue can be resolved with a higher priority.

    Thanks

  12. added a commit that references this issue on Sep 25, 2019
  13. mklim commented on Sep 25, 2019

    @mklim
    Contributor

    The work around has landed in the engine, but it will still take some time for it to roll into the framework and then the beta, dev, and finally stable channels.

    ETA: This rolled into flutter master at bcbe822.

  14. markmoskalenko commented on Sep 26, 2019

    @markmoskalenko

    Included in the assembly of the Russian language!
    Similar problem !!!!

  15. chulwoo-park commented on Nov 25, 2019

    @chulwoo-park
    Contributor

    This issue is still occurs when using the korean qwerty keyboard.
    We tested on beta channel(1.11.0).

    steps:

    1. Enter 가나.

    가나|

    1. Move the cursor to the center.

    가|나

    1. Enter 12.

    가12|나

    1. Move the cursor to the center.

    가1|2나

    1. Enter 가, then:

    가1가1가|2나

  16. GaryQian commented on Nov 26, 2019

    @GaryQian
    Contributor

    Thanks for the additional repro! The fix we landed was a workaround, and it doesn't seem to cover this case.

  17. timsneath commented on Nov 27, 2019

    @timsneath
  18. github-actions commented on Aug 25, 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.

  19. locked as resolved and limited conversation to collaborators on Aug 25, 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 problemscustomer: producte: device-specificOnly manifests on certain devicesframeworkflutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packagesplatform-androidAndroid applications specifically

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions