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

Removing the Paste as plaintext option from the insert and selection context menu #38210

Closed
wants to merge 12 commits into from

Conversation

fabOnReact
Copy link
Contributor

@fabOnReact fabOnReact commented Jul 6, 2023

Summary:

Remove Paste as plaintext from Android EditText context menu.
Related PR Over-riding onTextContextMenuItem in ReactEditText to copy/paste plain text instead of rich-text #38189.

What is the root cause of that problem?

Android EditText and iOS UITextField/UITextView have different copy/paste behavior.

  • Android TextInput copies/pastes rich text
  • iOS UITextField copies/pastes plain text.
iOS (react-native) Android (react-native)
Simulator.Screen.Recording.-.iPhone.14.Pro.-.2023-06-27.at.21.41.04.mp4
repro_android.mov

What changes do you think we should make in order to solve the problem?

The issue is a bug in react-native #31442:

  1. The JavaScript TextInput and ReactEditText Android state are not in sync
  2. The TextInput Android Native state over-rides the JavaScript state.
  3. onChangeText passes a plain text string to JavaScript, not rich text (text with spans and styles).

More info at Expensify/App#21411 (comment)

The solution consists of:

  1. PR Over-riding onTextContextMenuItem in ReactEditText to copy/paste plain text instead of rich-text #38189 (https://stackoverflow.com/a/45319485/7295772).
  2. PR Removing the Paste as plaintext option from the insert and selection context menu #38210

Changelog:

[ANDROID] [FIXED] - Remove Paste as plaintext from Android EditText context menu.

Test Plan:

Reproducing the issue on Android

2023-06-27.22-28-06.mp4

Fixing the issue on Android

Sourcecode https://github.com/fabriziobertoglio1987/text-input-cursor-flickering-android/blob/fix-copy-paste/app/src/main/java/com/example/myapplication/CustomEditText.java

2023-06-28.21-26-53.mp4

Testing the solution on React Native

2023-06-29.17-49-09.mp4

More tests at Expensify/App#21411 (comment)

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 6, 2023
@fabOnReact fabOnReact changed the title Remove Paste as plaintext from Android EditText context menu. Removing the Paste as plaintext option from the insert and selection context menu Jul 6, 2023
@fabOnReact fabOnReact changed the title Removing the Paste as plaintext option from the insert and selection context menu Removing the Paste as plaintext option from the insert and selection context menu Jul 6, 2023
@analysis-bot
Copy link

analysis-bot commented Jul 6, 2023

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,835,301 +218
android hermes armeabi-v7a 8,144,868 +201
android hermes x86 9,340,077 +208
android hermes x86_64 9,183,184 +213
android jsc arm64-v8a 9,447,189 +187
android jsc armeabi-v7a 8,628,813 +193
android jsc x86 9,529,290 +200
android jsc x86_64 9,773,072 +204

Base commit: 8ab9a77
Branch: main

@fabOnReact
Copy link
Contributor Author

#38189 (comment)

@fabOnReact fabOnReact marked this pull request as ready for review July 17, 2023 08:30
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jul 17, 2023
@fabOnReact fabOnReact marked this pull request as draft July 17, 2023 11:49
@fabOnReact fabOnReact marked this pull request as ready for review July 17, 2023 11:50
@fabOnReact fabOnReact marked this pull request as draft July 22, 2023 06:56
@fabOnReact fabOnReact closed this Jul 22, 2023
@fabOnReact
Copy link
Contributor Author

Changes from this PR moved to #38189 (review)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants