[Android, Accessibility] Modals break when pressing ESC on physical keyboard

未关闭
#56,411 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
android, react-native

调研方向

从链接的 Snack 复现代码和 Android Modal 处理开始,比较硬件返回路径与 ESC 键处理。确认按下 ESC 会调用 onRequestClose,并使 React modal 状态保持同步,然后在连接 Bluetooth 键盘的 Android 设备上验证相同的行为。

由索引模型根据 Issue 内容生成。

描述

API: Keyboard Component: Modal Needs: Triage :mag: Platform: Android
Description

When closing a Modal with ESC key from a Bluetooth keyboard on Android,
the modal closes natively but onRequestClose callback is not invoked.
This leaves React state out of sync.

Steps to reproduce
  1. Run the reproducer on Android device with Bluetooth keyboard connected
  2. Press "Open Modal" button
  3. Press hardware BACK button or use the BACK gesture -> "onRequestClose called!" alert appears ✅
  4. Press "Open Modal" again
  5. Press ESC key -> Modal closes but NO alert appears ❌
  6. Modal state is still 'true' in React but Modal is closed
  7. Press "Open Modal" again -> Nothing happens (state is already true)

BEWARE: after the state gets stuck you cannot tap on the screen anymore, you have to reach and activate the reset state button via keyboard.

EXPECTED: ESC should call onRequestClose (like back button does)
ACTUAL: Modal closes silently without calling any callbacks

React Native Version

0.84.1

Affected Platforms

Runtime - Android

Output of npx @react-native-community/cli info
System:
  OS: macOS 26.4
  CPU: (8) arm64 Apple M2
  Memory: 116.42 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 24.14.1
    path: /Users/XXX/.nvm/versions/node/v24.14.1/bin/node
  Yarn:
    version: 1.22.22
    path: /opt/homebrew/bin/yarn
  npm:
    version: 11.11.0
    path: /Users/XXX/.nvm/versions/node/v24.14.1/bin/npm
  Watchman:
    version: 2022.11.28.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /Users/XXX/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 25.2
      - iOS 26.2
      - macOS 26.2
      - tvOS 26.2
      - visionOS 26.2
      - watchOS 26.2
  Android SDK:
    API Levels:
      - "34"
      - "35"
      - "36"
    Build Tools:
      - 33.0.1
      - 34.0.0
      - 35.0.0
      - 36.0.0
    Android NDK: Not Found
IDEs:
  Android Studio: 2025.2 AI-252.25557.131.2521.14344949
  Xcode:
    version: 26.2/17C52
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.16
    path: /usr/bin/javac
  Ruby:
    version: 2.7.5
    path: /Users/XXX/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 20.1.3
    wanted: ^20.1.3
  react:
    installed: 19.2.3
    wanted: 19.2.3
  react-native:
    installed: 0.84.1
    wanted: 0.84.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true
Stacktrace or Logs
-
MANDATORY Reproducer

https://snack.expo.dev/@andreamartinez/react-native-modal-esc-key-bug

Screenshots and Videos

In the video the first modal closing is operated via Back gesture. When you see the blue outline on the buttons I am using the keyboard.

https://github.com/user-attachments/assets/aff72723-bc86-4f40-8c6e-cdcd86bd125d

主要语言
C++
星标
127k
派生
25.3k
平均合并
1 天 23 小时
30 天内合并 PR
4

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

react/react-native 的其他 Issue

查看 react/react-native 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。