diff --git a/patches/react-native/details.md b/patches/react-native/details.md index 66c1f2322689..33188e0c185a 100644 --- a/patches/react-native/details.md +++ b/patches/react-native/details.md @@ -74,10 +74,17 @@ ### [react-native+0.79.2+011+Add-onPaste-to-TextInput.patch](react-native+0.79.2+011+Add-onPaste-to-TextInput.patch) -- Reason: Adds onPaste event handler to TextInput component -- Upstream PR/issue: 🛑 -- E/App issue: 🛑 -- PR Introducing Patch: 🛑 +- Reasons: + - Adds `onPaste` callback to `TextInput` to support image pasting on native + - Fixes an issue where pasted image displays as binary text on some Android devices where rich clipboard data is stored in binary form + - Fixes an issue where pasting from WPS Office app crashes the app on Android where its content URI is not recognized by Android `ContentResolver` +- Upstream PR/issue: https://github.com/facebook/react-native/pull/45425 +- Upstream RFC: https://github.com/s77rt/discussions-and-proposals/blob/TextInput-onPaste/proposals/0000-textinput-onpaste.md +- E/App issue: + - https://github.com/Expensify/App/issues/41239 + - https://github.com/Expensify/App/issues/55304 + - https://github.com/Expensify/App/issues/63191 +- PR Introducing Patch: [#47203](https://github.com/Expensify/App/pull/47203) ### [react-native+0.79.2+012+alert-style.patch](react-native+0.79.2+012+alert-style.patch) diff --git a/patches/react-native/react-native+0.79.2+011+Add-onPaste-to-TextInput.patch b/patches/react-native/react-native+0.79.2+011+Add-onPaste-to-TextInput.patch index fe781d548dd7..80f24ebba436 100644 --- a/patches/react-native/react-native+0.79.2+011+Add-onPaste-to-TextInput.patch +++ b/patches/react-native/react-native+0.79.2+011+Add-onPaste-to-TextInput.patch @@ -445,7 +445,7 @@ index 0000000..bfb5819 + public void onPaste(String type, String data); +} 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 -index 42f2383..35bfa4d 100644 +index 42f2383..9a98163 100644 --- 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 @@ -9,6 +9,10 @@ package com.facebook.react.views.textinput; @@ -483,7 +483,7 @@ index 42f2383..35bfa4d 100644 mTextAttributes = new TextAttributes(); applyTextAttributes(); -@@ -335,8 +342,38 @@ public class ReactEditText extends AppCompatEditText { +@@ -335,8 +342,40 @@ public class ReactEditText extends AppCompatEditText { */ @Override public boolean onTextContextMenuItem(int id) { @@ -503,12 +503,14 @@ index 42f2383..35bfa4d 100644 + if (itemUri != null) { + ContentResolver cr = getReactContext(this).getContentResolver(); + type = cr.getType(itemUri); -+ data = itemUri.toString(); -+ if (mPasteWatcher != null) { -+ mPasteWatcher.onPaste(type, data); ++ if (type != null && !type.equals(ClipDescription.MIMETYPE_TEXT_PLAIN)) { ++ data = itemUri.toString(); ++ if (mPasteWatcher != null) { ++ mPasteWatcher.onPaste(type, data); ++ } ++ // Prevents default behavior to avoid inserting raw binary data into the text field ++ return true; + } -+ // Prevents default behavior to avoid inserting raw binary data into the text field -+ return true; + } + + if (clipData.getDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) { @@ -523,7 +525,7 @@ index 42f2383..35bfa4d 100644 } return super.onTextContextMenuItem(id); } -@@ -417,6 +454,10 @@ public class ReactEditText extends AppCompatEditText { +@@ -417,6 +456,10 @@ public class ReactEditText extends AppCompatEditText { mScrollWatcher = scrollWatcher; }