Android: with `enableKeyEvents` on, a focused View inside a `<Modal>` never receives `onKeyDown`
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 54/100
調査の方向性
Start with ReactModalHostView.kt, especially DialogRootViewGroup and the dialog's OnKeyListener; compare their key handling with ReactRootView.java and ReactSurfaceView.kt, where JSKeyDispatcher routes events and tracks focus. Reproduce with the linked app and enableKeyEvents enabled. Done when a focused View inside a Modal receives onKeyDown and onKeyUp, while Back or Escape still triggers onRequestClose.
索引モデルが issue の本文から書いたものです。
説明
Description
With ReactNativeFeatureFlags.enableKeyEvents() on, React Native Android sends a View's onKeyDown / onKeyUp from the React root's own key dispatch: ReactRootView.dispatchKeyEvent (L327) and ReactSurfaceView.dispatchJSKeyEvent (L200), each with a JSKeyDispatcher that tracks the focused child. A <Modal> renders into a dialog window whose root is ReactModalHostView.DialogRootViewGroup (L516), which has no key dispatch and no focus tracking, so a View inside a Modal receives no key event even while it holds focus. The dialog's OnKeyListener (L313) only turns Back or Escape into onRequestClose.
Steps to reproduce
The reproducer turns enableKeyEvents on in MainApplication.kt after loadReactNative, and renders a focusable View with onKeyDown that shows the last key it got, a button that opens a <Modal>, and the same View in the Modal.
- Clone the reproducer; in
ReproducerApp:yarn install, thencd android && ./gradlew assembleReleaseandadb install -r app/build/outputs/apk/release/app-release.apk. - Start the app.
adb shell input keyevent KEYCODE_TABfocuses the first View, andadb shell input keyevent KEYCODE_Amakes it showOutside the Modal, last key: a. - Tap Open the Modal, then
adb shell input keyevent KEYCODE_TAB, which focuses the View in the Modal, andadb shell input keyevent KEYCODE_A.
Expected: Inside the Modal, last key: a.
Seen: Inside the Modal, last key: none, with that View focused.
React Native Version
0.88.1
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: 201.56 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\yevhe.YEVHENII\AppData\Roaming\npm\yarn.CMD
npm:
version: 12.2.1
path: C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK:
API Levels:
- "33"
- "35"
- "35"
- "35"
- "36"
- "37"
Build Tools:
- 35.0.0
- 36.0.0
- 36.1.0
- 37.0.0
System Images:
- android-26 | Google APIs Intel x86_64 Atom
- android-28 | Google APIs Intel x86_64 Atom
- android-29 | Google APIs Intel x86_64 Atom
- android-30 | Google APIs Intel x86_64 Atom
- android-31 | Google APIs Intel x86_64 Atom
- android-32 | Google APIs Intel x86_64 Atom
- android-33 | Google APIs Intel x86_64 Atom
- android-34 | Google APIs Intel x86_64 Atom
- android-35 | Google APIs Intel x86_64 Atom
- android-36.1 | Google Play Intel x86_64 Atom
- android-36.1 | Pre-Release 16 KB Page Size Google Play Intel x86_64 Atom
- android-37.0 | Google APIs Intel x86_64 Atom
Android NDK: Not Found
Windows SDK: Not Found
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: 20.2.0
wanted: 20.2.0
react:
installed: 19.3.0
wanted: 19.3.0
react-native:
installed: 0.88.1
wanted: 0.88.1
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. The focused node (uiautomator dump) and the text of each View after each step, on a Galaxy S23 (Android 14):
{"device":"SM-S911B, Android 14"}
{"step":"started","focused":"none","shows":["Outside the Modal, last key: none"]}
{"step":"KEYCODE_TAB","focused":"outside-target","shows":["Outside the Modal, last key: none"]}
{"step":"KEYCODE_A","focused":"outside-target","shows":["Outside the Modal, last key: a"]}
{"step":"tapped Open the Modal","focused":"none","shows":["Inside the Modal, last key: none"]}
{"step":"KEYCODE_TAB in the Modal","focused":"inside-target","shows":["Inside the Modal, last key: none"]}
{"step":"KEYCODE_A in the Modal","focused":"inside-target","shows":["Inside the Modal, last key: none"]}
On main at c12d0b3e74, ReactModalHostView.kt differs from 0.88.1 only in dismissing a dialog of a destroyed Activity and in the navigation bar contrast of a transparent one; DialogRootViewGroup is the same.
MANDATORY Reproducer
https://github.com/YevheniiKotyrlo/rn-android-modal-key-events
Screenshots and Videos
No response
- 主要言語
- C++
- スター
- 127k
- フォーク
- 25.5k
- 平均マージ
- 3日 22時間
- マージ済み PR(30日)
- 235
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
react/react-native のほかの issue
-
Needs: Author Feedback Needs: Repro
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
react/react-native#60059 · コメント 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 が 4 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
react/react-native#59939 ·
メンテナーはふだん 2 日以内に返信
-
iOS Fabric pointer-handler reset leaves the next lone touch non-primary対応中かも @alleneubank が 6 日前に担当しました。 オープン
難易度 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
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
petercorke/robotics-toolbox-python#943 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area:build bug
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
NatronGitHub/openfx-arena#71 ·
メンテナーはふだん 1 日以内に返信
-
upstream-watcher: Netflix/vmaf cf677baaa039 is not ported対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンupstream-blocked
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
ROCm/FastFlowLM#1057 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
NatronGitHub/openfx-gmic#45 ·
メンテナーはふだん 1 日以内に返信