Android: with view recycling on, a recycled View keeps its nextFocusLeft
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 78/100
调研方向
阅读 ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java 中的 BaseViewManager.prepareToRecycleView,并将其中焦点属性的重置与设置 nextFocusLeftId 的 ReactViewManager.kt 进行比较。rn-recycled-view-next-focus-left 中的复现示例表明,回收后的视图仍保留旧值。请验证回收时会清除此值,同时具有自身 nextFocusLeft 的视图仍会使用该目标。
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- C++
- 星标
- 127k
- 派生
- 25.5k
- 平均合并
- 3 天 19 小时
- 30 天内合并 PR
- 291
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
react/react-native 的其他 Issue
-
Needs: Author Feedback Needs: Repro
难度 2/5 1-3 小时 新手友好度 74/100
react/react-native#60091 · 1 条评论 ·
维护者通常 2 天内回复
-
Needs: Triage :mag:
难度 2/5 1-3 小时 新手友好度 70/100
react/react-native#60000 ·
维护者通常 2 天内回复
-
`yarn test-ios` exits before building RNTester: `objc-test.sh` launches the WebSocket server script #59433 deleted可能已有人在做 @lazerg 于 7 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
react/react-native#59939 ·
维护者通常 2 天内回复
-
iOS Fabric pointer-handler reset leaves the next lone touch non-primary可能已有人在做 @alleneubank 于 9 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
react/react-native#59919 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
react/react-native#59722 ·
维护者通常 2 天内回复
查看 react/react-native 的全部 Issue
相似的 Issue
-
documentation
难度 2/5 1-3 小时 新手友好度 63/100
-
tests: ofx_render_test doesn't compile against FFmpeg 4.x (const AVCodec* to av_find_best_stream)未关闭
难度 2/5 1-3 小时 新手友好度 78/100
NatronGitHub/openfx-io#221 · 1 条评论 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
subsurface/subsurface#5145 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
rohaquinlop/cognity#5 ·
-
Grendel
难度 1/5 1-3 小时 新手友好度 86/100
tenstorrent/tt-umd#3980 ·
维护者通常 3 天内回复