Android: with view recycling on, a recycled View keeps its nextFocusLeft
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
Hướng nghiên cứu
Đọc BaseViewManager.prepareToRecycleView trong ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java và so sánh việc đặt lại các thuộc tính tiêu điểm với ReactViewManager.kt, nơi nextFocusLeftId được đặt. Trường hợp tái hiện tại rn-recycled-view-next-focus-left cho thấy view được tái chế vẫn giữ giá trị cũ. Hãy xác minh rằng việc tái chế xóa giá trị đó, trong khi một view có nextFocusLeft riêng vẫn sử dụng đích đó.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- C++
- Star
- 127k
- Fork
- 25.5k
- Merge trung bình
- 3 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 291
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của react/react-native
-
Needs: Author Feedback Needs: Repro
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
react/react-native#60091 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Needs: Triage :mag:
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
react/react-native#60000 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
`yarn test-ios` exits before building RNTester: `objc-test.sh` launches the WebSocket server script #59433 deletedCó thể đã có người làm @lazerg đã nhận 7 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
react/react-native#59939 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
iOS Fabric pointer-handler reset leaves the next lone touch non-primaryCó thể đã có người làm @alleneubank đã nhận 9 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
react/react-native#59919 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
react/react-native#59722 ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của react/react-native
Issue tương tự
-
Level format documentationĐang mởdocumentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 63/100
-
tests: ofx_render_test doesn't compile against FFmpeg 4.x (const AVCodec* to av_find_best_stream)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
NatronGitHub/openfx-io#221 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
subsurface/subsurface#5145 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
rohaquinlop/cognity#5 ·
-
Grendel
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 86/100
tenstorrent/tt-umd#3980 ·
Maintainer thường phản hồi trong vòng 3 ngày