engine icon indicating copy to clipboard operation
engine copied to clipboard

Android Input Failed When TextInputType Is Phone, Number

Open JsouLiang opened this issue 3 years ago • 6 comments

Fix Issue: 98352

In current case is not cursor selector but current logic number input is will check the Selection range

When the TextInputType is Number, and you input text, the keyboard will sendKeyEvent, and next entry the handleKeyEvent method

public boolean handleKeyEvent(KeyEvent event) {
   ...
        // Enter a character.
        final int selStart = Selection.getSelectionStart(mEditable);
        final int selEnd = Selection.getSelectionEnd(mEditable);
        final int character = event.getUnicodeChar();
        if (selStart < 0 || selEnd < 0 || character == 0) {
          return false;
        }
...
  }

When first number entry this method the selStart and selEnd will be -1, because there is no cursor and thus the Selection.start is not attach. The getSelectionStart will return -1

We need to support logic that without a cursor, and need support delete action.

Pre-launch Checklist

  • [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • [x] I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides].
  • [x] I listed at least one issue that this PR fixes in the description above.
  • [x] I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See [testing the engine] for instructions on writing and running engine tests.
  • [x] I updated/added relevant documentation (doc comments with ///).
  • [x] I signed the [CLA].
  • [x] All existing and new tests are passing.

JsouLiang avatar Feb 21 '22 12:02 JsouLiang

I think there is an open question for @LongCatIsLooong

chinmaygarde avatar Mar 24 '22 20:03 chinmaygarde

From PR review triage: There are open questions for @JsouLiang and @gspencergoog

zanderso avatar Mar 31 '22 20:03 zanderso

@JsouLiang Hi there again from PR triage. Are you interested in continuing with this PR? If so, it looks like there are some open questions for you. Thanks!

zanderso avatar Apr 07 '22 20:04 zanderso

@zanderso hey, yes i am interested in continuing with this PR, but i have some problems need to ask @LongCatIsLooong. Thanks.

JsouLiang avatar Apr 08 '22 10:04 JsouLiang

cc @LongCatIsLooong Are you able to reply to @JsouLiang query?

chinmaygarde avatar May 19 '22 20:05 chinmaygarde

Sorry for the delayed reply. @JsouLiang looks like the handleDelete implementation in the pull request doesn't handle surrogate pairs or combining characters. The logic that handles that currently lives in the framework since that's much easier to maintain than implementing/maintaining the same thing for each platform. There's ongoing work to expose more things to help developers build their own TextInputClients from scratch but for now should they choose to implement TextInputClient themselves, they'll have to handle delete themselves.

LongCatIsLooong avatar Aug 02 '22 23:08 LongCatIsLooong

Is this any update? I still met this issue on android with Flutter v3.7.12

nhanvhn avatar Jul 06 '23 08:07 nhanvhn