Skip to content

Commit c97352a

Browse files
authored
Merge pull request Expensify#64457 from mkzie2/mkzie2-issue/63191
2 parents 9ee3cae + 504c2d7 commit c97352a

2 files changed

Lines changed: 21 additions & 12 deletions

File tree

patches/react-native/details.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,17 @@
7474

7575
### [react-native+0.79.2+011+Add-onPaste-to-TextInput.patch](react-native+0.79.2+011+Add-onPaste-to-TextInput.patch)
7676

77-
- Reason: Adds onPaste event handler to TextInput component
78-
- Upstream PR/issue: 🛑
79-
- E/App issue: 🛑
80-
- PR Introducing Patch: 🛑
77+
- Reasons:
78+
- Adds `onPaste` callback to `TextInput` to support image pasting on native
79+
- Fixes an issue where pasted image displays as binary text on some Android devices where rich clipboard data is stored in binary form
80+
- Fixes an issue where pasting from WPS Office app crashes the app on Android where its content URI is not recognized by Android `ContentResolver`
81+
- Upstream PR/issue: https://github.com/facebook/react-native/pull/45425
82+
- Upstream RFC: https://github.com/s77rt/discussions-and-proposals/blob/TextInput-onPaste/proposals/0000-textinput-onpaste.md
83+
- E/App issue:
84+
- https://github.com/Expensify/App/issues/41239
85+
- https://github.com/Expensify/App/issues/55304
86+
- https://github.com/Expensify/App/issues/63191
87+
- PR Introducing Patch: [#47203](https://github.com/Expensify/App/pull/47203)
8188

8289
### [react-native+0.79.2+012+alert-style.patch](react-native+0.79.2+012+alert-style.patch)
8390

patches/react-native/react-native+0.79.2+011+Add-onPaste-to-TextInput.patch

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ index 0000000..bfb5819
445445
+ public void onPaste(String type, String data);
446446
+}
447447
diff --git a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java
448-
index 42f2383..35bfa4d 100644
448+
index 42f2383..9a98163 100644
449449
--- a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java
450450
+++ b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java
451451
@@ -9,6 +9,10 @@ package com.facebook.react.views.textinput;
@@ -483,7 +483,7 @@ index 42f2383..35bfa4d 100644
483483
mTextAttributes = new TextAttributes();
484484

485485
applyTextAttributes();
486-
@@ -335,8 +342,38 @@ public class ReactEditText extends AppCompatEditText {
486+
@@ -335,8 +342,40 @@ public class ReactEditText extends AppCompatEditText {
487487
*/
488488
@Override
489489
public boolean onTextContextMenuItem(int id) {
@@ -503,12 +503,14 @@ index 42f2383..35bfa4d 100644
503503
+ if (itemUri != null) {
504504
+ ContentResolver cr = getReactContext(this).getContentResolver();
505505
+ type = cr.getType(itemUri);
506-
+ data = itemUri.toString();
507-
+ if (mPasteWatcher != null) {
508-
+ mPasteWatcher.onPaste(type, data);
506+
+ if (type != null && !type.equals(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
507+
+ data = itemUri.toString();
508+
+ if (mPasteWatcher != null) {
509+
+ mPasteWatcher.onPaste(type, data);
510+
+ }
511+
+ // Prevents default behavior to avoid inserting raw binary data into the text field
512+
+ return true;
509513
+ }
510-
+ // Prevents default behavior to avoid inserting raw binary data into the text field
511-
+ return true;
512514
+ }
513515
+
514516
+ if (clipData.getDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
@@ -523,7 +525,7 @@ index 42f2383..35bfa4d 100644
523525
}
524526
return super.onTextContextMenuItem(id);
525527
}
526-
@@ -417,6 +454,10 @@ public class ReactEditText extends AppCompatEditText {
528+
@@ -417,6 +456,10 @@ public class ReactEditText extends AppCompatEditText {
527529
mScrollWatcher = scrollWatcher;
528530
}
529531

0 commit comments

Comments
 (0)