Android: with view recycling on, a recycled View keeps its nextFocusLeft
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Read BaseViewManager.prepareToRecycleView in ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java and compare its focus-property resets with ReactViewManager.kt, where nextFocusLeftId is set. The reproducer at rn-recycled-view-next-focus-left demonstrates the recycled view retaining the old value. Verify that recycling clears it while a view with its own nextFocusLeft still uses that target.
Written by the indexing model from the issue text.
Description
Description
With view recycling on (enableViewRecycling), a View that mounts on a recycled ReactViewGroup keeps the nextFocusLeft of the view that used it before, so Arrow Left (D-pad Left) from it moves focus to that old target.
BaseViewManager.prepareToRecycleView resets nextFocusDown, nextFocusForward, nextFocusRight and nextFocusUp to View.NO_ID (L155-L161), but not nextFocusLeft, which ReactViewManager sets as nextFocusLeftId (L260-L263). A new View without the prop never sets it back.
Steps to reproduce
The reproducer turns enableViewRecycling on in MainApplication and renders a row of three focusable Pressables: "Target", "Neighbour" and "Old subject", whose nextFocusLeft is "Target". Once Arrow Left from "Old subject" has focused "Target", "Old subject" unmounts, and a second later "New subject", without nextFocusLeft, mounts in its place. MainActivity logs which Android view instance each subject is drawn by and its nextFocusLeftId.
- Clone the reproducer and, with one Android device attached, run
./reproduce.sh. It builds and installs the release APK, presses the arrow keys withadb shell input keyeventand reads which view holds focus fromuiautomator dump. - Or by hand:
cd ReproducerApp/android && ./gradlew assembleRelease && adb install -r app/build/outputs/apk/release/app-release.apk, open the app, and with a keyboard or D-pad:- Press Right until "Old subject" holds focus, then Left: focus goes to "Target".
- A second later "New subject" replaces "Old subject". Press Right until "New subject" holds focus, then Left.
Expected: Arrow Left from "New subject" focuses "Neighbour", the view on its left; a nextFocusLeft that a view sets itself still decides where Left goes, as it does for "Old subject".
Seen: it focuses "Target", "Old subject"'s nextFocusLeft.
React Native Version
0.90.0-nightly-20261119-f4f8b6a1f
Affected Platforms
Runtime - Android
Output of npx @react-native-community/cli info
System:
OS: Windows 11 10.0.26300
CPU: "(32) x64 AMD Ryzen 9 9950X3D 16-Core Processor "
Memory: 170.02 GB / 255.67 GB
Binaries:
Node:
version: 26.12.1
path: C:\Program Files\nodejs\node.EXE
Yarn:
version: 1.22.22
path: C:\Users\<user>\AppData\Roaming\npm\yarn.CMD
npm:
version: 12.2.1
path: C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK: Not Found
Windows SDK:
AllowDevelopmentWithoutDevLicense: Enabled
Versions:
- 10.0.19041.0
- 10.0.26100.0
IDEs:
Android Studio: AI-262.9437.185.2621.16467767
Visual Studio: Not Found
Languages:
Java:
version: 17.0.20.1
path: C:\Program Files\Microsoft\jdk-17.0.20.101-hotspot\bin\javac.EXE
Ruby: Not Found
npmPackages:
"@react-native-community/cli":
installed: 21.0.0
wanted: 21.0.0
react:
installed: 19.3.0
wanted: 19.3.0
react-native:
installed: 0.90.0-nightly-20261119-f4f8b6a1f
wanted: 0.90.0-nightly-20261119-f4f8b6a1f
react-native-windows: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: Not found
newArchEnabled: Not found
Stacktrace or Logs
No error is logged. ./reproduce.sh at the reproducer's fb8a697, on a Galaxy S23:
device: SM-S911B, Android 14 (API 34), arm64-v8a
react-native 0.90.0-nightly-20261119-f4f8b6a1f
== ./gradlew :app:assembleRelease -PreactNativeArchitectures=arm64-v8a
enableViewRecycling true
== 1. Arrow Right to the old subject (nextFocusLeft = Target), then Arrow Left
focused: Old subject
Arrow Left from the old subject focused: Target
== 2. The old subject unmounts; a new subject without nextFocusLeft mounts
subject-old: view instance 226627177, id 30, nextFocusLeftId 10
subject-new: view instance 226627177, id 48, nextFocusLeftId 10
the new subject reuses the old subject's Android view: yes
== 3. Arrow Right to the new subject, then Arrow Left
focused: New subject
Arrow Left from the new subject focused: Target
SUMMARY: Arrow Left from the new subject, which has no nextFocusLeft, went to "Target", the old subject's nextFocusLeft; expected "Neighbour"
MANDATORY Reproducer
https://github.com/YevheniiKotyrlo/rn-recycled-view-next-focus-left
Screenshots and Videos
No response
- Dominant language
- C++
- Stars
- 127k
- Forks
- 25.5k
- Avg merge
- 3d 19h
- Merged PRs (30d)
- 291
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing 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.
More from react/react-native
-
Needs: Author Feedback Needs: Repro
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
react/react-native#60091 · 1 comment ·
Maintainers usually reply within 2 days
-
Needs: Triage :mag:
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
react/react-native#60000 ·
Maintainers usually reply within 2 days
-
`yarn test-ios` exits before building RNTester: `objc-test.sh` launches the WebSocket server script #59433 deletedPossibly taken @lazerg claimed this 7 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
react/react-native#59939 ·
Maintainers usually reply within 2 days
-
iOS Fabric pointer-handler reset leaves the next lone touch non-primaryPossibly taken @alleneubank claimed this 9 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
react/react-native#59919 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
react/react-native#59722 ·
Maintainers usually reply within 2 days
All issues in react/react-native
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
protocolbuffers/protobuf#31768 ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 2 days
-
tests: ofx_render_test doesn't compile against FFmpeg 4.x (const AVCodec* to av_find_best_stream)Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
NatronGitHub/openfx-io#221 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
subsurface/subsurface#5145 ·
Maintainers usually reply within 2 days