Skip to content

Android: a TextInput takes hardware-keyboard focus even with tabIndex={-1} or focusable={false} #60194

Open

Description

@YevheniiKotyrlo

Description

On Android, a TextInput with tabIndex={-1} or focusable={false} still takes hardware-keyboard focus: Tab, Shift+Tab and the D-pad or arrow keys land on it. React Native documents focusable as "whether this View should be focusable with a non-touch input device, eg. receive focus with a hardware keyboard", and tabIndex={-1} as "View is not focusable". TextInput inherits both from View.

TextInput passes both to the native component as focusable (TextInput.js L588), and focusable is a valid attribute of every Android host component (BaseViewConfig.android.js L402). ReactTextInputManager has no @ReactProp(name = "focusable") setter (ReactTextInputManager.kt), so the prop reaches nothing and ReactEditText stays focusable, as an EditText is by default.

Related: #59048 adds the keyboard exclusion for View, #59139 for Text, and #60168 reports the same for Image.

Steps to reproduce

The reproducer renders, top to bottom: a Pressable "first button", <TextInput accessibilityLabel="input with tabIndex -1" tabIndex={-1} />, <TextInput accessibilityLabel="input with focusable false" focusable={false} />, and a Pressable "second button".

  1. Build and install the release APK: cd ReproducerApp && yarn install && cd android && ./gradlew assembleRelease && adb install -r app/build/outputs/apk/release/app-release.apk.
  2. Open the app, attach a hardware keyboard and press Tab repeatedly.
  3. From the first button, press the down arrow (D-pad Down) three times.

Or run ./reproduce.sh with one Android device attached: it builds and installs the app, then for each of Tab, Shift+Tab and D-pad Down starts the app afresh, presses the key six times through adb shell input and reads which view holds focus after each press from uiautomator dump. It exits 1 while either input takes focus.

Expected: neither input takes keyboard focus. Tab and Shift+Tab move between the two buttons only, D-pad Down goes from the first button to the second, and both inputs still take focus when tapped.
Seen: Tab goes first button → second button → "input with tabIndex -1" → "input with focusable false" → first button; Shift+Tab goes the reverse way through both inputs; D-pad Down goes through both inputs to the second button.

React Native Version

0.90.0-nightly-20261120-bbfd39149

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: 138.06 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-alpha.1
    wanted: 21.0.0-alpha.1
  react:
    installed: 19.3.0
    wanted: 19.3.0
  react-native:
    installed: 0.90.0-nightly-20261120-bbfd39149
    wanted: 0.90.0-nightly-20261120-bbfd39149
  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

./reproduce.sh at the reproducer's 7990bed, on an Android 15 emulator; no error is logged:

device: sdk_gphone64_x86_64, Android 15 (API 35), x86_64
react-native 0.90.0-nightly-20261120-bbfd39149
== ./gradlew :app:assembleRelease -PreactNativeArchitectures=x86_64
== Tab, 6 presses from a fresh launch
  Tab 1: "first button" holds focus
  Tab 2: "second button" holds focus
  Tab 3: "input with tabIndex -1" holds focus
  Tab 4: "input with focusable false" holds focus
  Tab 5: "first button" holds focus
  Tab 6: "second button" holds focus
== Shift+Tab, 6 presses from a fresh launch
  Shift+Tab 1: "first button" holds focus
  Shift+Tab 2: "input with focusable false" holds focus
[…]
  Shift+Tab 3: "input with tabIndex -1" holds focus
  Shift+Tab 4: "second button" holds focus
  Shift+Tab 5: "first button" holds focus
  Shift+Tab 6: "input with focusable false" holds focus
== D-pad Down, 6 presses from a fresh launch
  D-pad Down 1: "first button" holds focus
  D-pad Down 2: "input with tabIndex -1" holds focus
  D-pad Down 3: "input with focusable false" holds focus
  D-pad Down 4: "second button" holds focus
  D-pad Down 5: "second button" holds focus
  D-pad Down 6: "second button" holds focus
SUMMARY: a TextInput with tabIndex={-1} or focusable={false} takes keyboard focus: Tab lands on "input with tabIndex -1" and "input with focusable false"; Shift+Tab lands on "input with focusable false" and "input with tabIndex -1"; D-pad Down lands on "input with tabIndex -1" and "input with focusable false"

MANDATORY Reproducer

https://github.com/YevheniiKotyrlo/rn-text-input-focusable-keyboard-focus

Screenshots and Videos

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions