Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

State update breaks CJK language input mode in single-line TextInput, after iOS 15 #32503

Closed
kmsbernard opened this issue Oct 30, 2021 · 2 comments
Labels
Component: TextInput Related to the TextInput component. Needs: Attention Issues where the author has responded to feedback. Platform: iOS iOS applications. Resolution: Locked This issue was locked by the bot.

Comments

@kmsbernard
Copy link
Contributor

kmsbernard commented Oct 30, 2021

Description

This is a somewhat historic issue which has been reported several times. There were also PRs to fit it.

It seems that there was some internal behavior changes in UIKit TextField after iOS 15, and setSelectedTextRange call breaks input mode of CJK languages.

if (selection.empty) {
// Maintaining a cursor position relative to the end of the old text.
NSInteger offsetStart =
[self.backedTextInputView offsetFromPosition:self.backedTextInputView.beginningOfDocument
toPosition:selection.start];
NSInteger offsetFromEnd = oldTextLength - offsetStart;
NSInteger newOffset = attributedText.string.length - offsetFromEnd;
UITextPosition *position =
[self.backedTextInputView positionFromPosition:self.backedTextInputView.beginningOfDocument
offset:newOffset];
[self.backedTextInputView setSelectedTextRange:[self.backedTextInputView textRangeFromPosition:position toPosition:position]
notifyDelegate:YES];
}

I'm now trying to resolve this issue, but it is hard to find a safe workaround. Any suggestions or ideas would be appreciated.

Version

0.65.1

Output of react-native info

System:
    OS: macOS 12.0.1
    CPU: (8) x64 Apple M1
    Memory: 23.47 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.18.1 - /var/folders/hq/9ypzt1l953g6f38wmksf9zqm0000gn/T/yarn--1635561018227-0.1440883449375101/node
    Yarn: 1.22.10 - /var/folders/hq/9ypzt1l953g6f38wmksf9zqm0000gn/T/yarn--1635561018227-0.1440883449375101/yarn
    npm: 6.14.15 - ~/.nvm/versions/node/v14.18.1/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.11.2 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.0.1, iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0
    Android SDK: Not Found
  IDEs:
    Android Studio: 2020.3 AI-203.7717.56.2031.7621141
    Xcode: 13.1/13A1030d - /usr/bin/xcodebuild
  Languages:
    Java: 16.0.1 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.1 
    react-native: 0.65.1 => 0.64.2 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to reproduce

Type some Korean characters in TextInput in iOS 15, such as "하늘". Then move the cursor to the beginning of the text, and then type any text. Let's say I typed "파란" (characters ,,,,) this time. The expected text is "파란하늘" However, the actual result is "ㅍㅏㄹㅏㄴ하늘"

Snack, code example, screenshot, or link to a repository

@react-native-bot react-native-bot added Component: TextInput Related to the TextInput component. Platform: iOS iOS applications. Needs: Author Feedback Needs: Environment Info Please run `react-native info` and edit your issue with that command's output. and removed Needs: Triage 🔍 labels Oct 30, 2021
@github-actions
Copy link

⚠️ Missing Environment Information
ℹ️ Your issue may be missing information about your development environment. You can obtain the missing information by running react-native info in a console.

@kmsbernard
Copy link
Contributor Author

For any others suffer with this issue, here is the patch-package file from the PR #32523: https://gist.github.com/bernard-kms/8f6bb978b3609b7f140467d59074a0fc

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Nov 23, 2021
@react-native-bot react-native-bot removed the Needs: Environment Info Please run `react-native info` and edit your issue with that command's output. label Nov 23, 2021
ShikaSD pushed a commit that referenced this issue Feb 22, 2022
Summary:
<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->

Fix #32503

Updating the attributed text in TextView/TextField while inputting Korean language will break input mechanism of the Korean alphabet. This results unexpected text input.

This PR supersedes the previous fixes: #19809, #22546

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[iOS] [Fixed] - Fix a broken input for the Korean alphabet in TextInput

Pull Request resolved: #32523

Test Plan: https://user-images.githubusercontent.com/20317121/140013434-1674c391-54d6-4410-b4c1-c633697e639d.mov

Reviewed By: lunaleaps, sammy-SC

Differential Revision: D32470543

Pulled By: philIip

fbshipit-source-id: e7e34bd362fa2ab2ca579103db01ad8d1a891c35
ShikaSD pushed a commit that referenced this issue Feb 24, 2022
Summary:
<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->

Fix #32503

Updating the attributed text in TextView/TextField while inputting Korean language will break input mechanism of the Korean alphabet. This results unexpected text input.

This PR supersedes the previous fixes: #19809, #22546

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[iOS] [Fixed] - Fix a broken input for the Korean alphabet in TextInput

Pull Request resolved: #32523

Test Plan: https://user-images.githubusercontent.com/20317121/140013434-1674c391-54d6-4410-b4c1-c633697e639d.mov

Reviewed By: lunaleaps, sammy-SC

Differential Revision: D32470543

Pulled By: philIip

fbshipit-source-id: e7e34bd362fa2ab2ca579103db01ad8d1a891c35
@facebook facebook locked as resolved and limited conversation to collaborators Feb 10, 2023
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Feb 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Component: TextInput Related to the TextInput component. Needs: Attention Issues where the author has responded to feedback. Platform: iOS iOS applications. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants