mattermost / mattermost/react-native-paste-input
v2 paste interception silently bails on RN 0.76+ Fabric (uses `__nativeTag` which is undefined)
Nobody has claimed this yet.
- Dominant language
- Objective-C
- Stars
- 213
- Forks
- 38
- Avg merge
- 12h 25m
- Merged PRs (30d)
- 1
Description
Summary
On v2.0.0 / v2.0.1, the iOS paste interception silently fails to register on RN 0.76+ with the New Architecture (Fabric) enabled. The Edit Menu / QuickType "Paste" / long-press → Paste actions fall through to the default UITextView paste handler, which does nothing for image-only clipboard contents — making it look like nothing happens on paste.
Root cause
PasteInputIOSComponent reads the React Native tag via the __nativeTag property (double underscore):
// src/PasteInput.tsx
const nativeTag = textInputRef.current?.__nativeTag;
if (!nativeTag) {
if (__DEV__) {
console.warn('[PasteInput] Could not get native tag from ref');
}
return;
}
That property name is from the legacy renderer. Under Fabric (RN ≥ 0.76 with RCT_NEW_ARCH_ENABLED=1), the renderer exposes the tag as _nativeTag (single underscore) on the component instance — see e.g. react-native@0.83.6 Libraries/Renderer/implementations/ReactNativeRenderer-prod.js line ~1372:
var tag = inst._nativeTag;
So on Fabric textInputRef.current?.__nativeTag is undefined, the useEffect bails before calling NativePasteInputModule.registerTextInput, and the native module never attaches its paste: swizzle to the underlying UITextView. In __DEV__ this surfaces as the [PasteInput] Could not get native tag from ref console warning; in release builds it's a silent no-op.
Repro
- RN ≥ 0.76 with new arch on (
RCT_NEW_ARCH_ENABLED=1) - v2.0.0 or v2.0.1 installed
- Mount a
<PasteInput onPaste={...} />and focus it - Copy an image to the clipboard (host macOS → iOS Simulator works;
public.pngon the pasteboard) - Tap the system Paste affordance — no
onPasteevent fires; no JS callback; in DEV the warning prints once at mount
Confirmed on RN 0.83.6 + Expo 55.0.16 + new arch enabled.
Suggested fix
Use findNodeHandle from react-native, which is the public API and works across both legacy and Fabric (returns the underlying _nativeTag on Fabric):
import { findNodeHandle } from 'react-native';
const nativeTag = textInputRef.current
? findNodeHandle(textInputRef.current)
: null;
findNodeHandle is a thin wrapper around the same renderer-internal tag lookup, just with the correct property name per renderer.
Happy to send a PR.
Workaround
For anyone hitting this before a fix lands, a patch-package / pnpm patch diff against lib/commonjs/PasteInput.js and lib/module/PasteInput.js swapping textInputRef.current?.__nativeTag for findNodeHandle(textInputRef.current) (with the import added in lib/module/PasteInput.js) restores paste interception.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/PasteInput.tsx around line 83 and trace the useEffect path that obtains the native tag and calls NativePasteInputModule.registerTextInput. Reproduce on RN 0.76+ with Fabric enabled and image-only clipboard content; done when paste interception registers and onPaste fires without the development warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, react-native, typescript
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100