react / react/react-native

Unable to move cursor in absolutely positioned TextInput on Android when parent View has zIndex

Offen
#51,469 5 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Component: TextInput Issue: Author Provided Repro Platform: Android
Vorherrschende Sprache
C++
Sterne
127k
Forks
25.3k
Ø Merge
1 T. 23 Std.
Gemergte PRs (30 T.)
4

Beschreibung

Description

On Android, when a TextInput is absolutely positioned and its parent View has a zIndex style property applied, the cursor within the TextInput cannot be moved after initial focus. Tapping on different parts of the TextInput does not change the cursor's position.

import React from 'react';
import {View, TextInput} from 'react-native';

export default function App() {
  return (
    <View style={{flex: 1, backgroundColor: '#fff'}}>
      <View
        style={{
          // Unable to move cursor if we add zIndex here
          zIndex: 1,
        }}>
        <TextInput
          style={{
            height: 40,
            backgroundColor: 'pink',
            width: '100%',
            position: 'absolute',
            top: 200,
          }}
        />
      </View>
    </View>
  );
}

Steps to reproduce
  1. Clone the reproduction repository.
  2. Run yarn android.
  3. Type some text into the TextInput.
  4. Try to move the cursor.
React Native Version

0.79.2

Affected Platforms

Runtime - Android

Output of npx @react-native-community/cli info
System:
  OS: macOS 15.3.2
  CPU: (10) arm64 Apple M4
  Memory: 113.78 MB / 24.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.18.1
    path: /usr/local/bin/node
  Yarn:
    version: 1.22.10
    path: /usr/local/bin/yarn
  npm:
    version: 8.15.0
    path: /usr/local/bin/npm
  Watchman: Not Found
Managers:
  CocoaPods:
    version: 1.11.3
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.4
      - iOS 18.4
      - macOS 15.4
      - tvOS 18.4
      - visionOS 2.4
      - watchOS 11.4
  Android SDK:
    Android NDK: 22.1.7171670
IDEs:
  Android Studio: 2024.3 AI-243.24978.46.2431.13208083
  Xcode:
    version: 16.3/16E140
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.12
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 18.0.0
    wanted: 18.0.0
  react:
    installed: 19.0.0
    wanted: 19.0.0
  react-native:
    installed: 0.79.2
    wanted: 0.79.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: false
Stacktrace or Logs
---
no error log
---
MANDATORY Reproducer

https://github.com/SeekingLight233/RnTextInputIssue

Screenshots and Videos

https://github.com/user-attachments/assets/4bfa61e9-f1b5-4746-8906-3864221fda48

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit dem obligatorischen Reproduktions-Repository und führe yarn android aus, um zu bestätigen, dass das Hinzufügen von zIndex zum übergeordneten Element die Cursorbewegung im absolut positionierten TextInput verhindert. Vergleiche das Verhalten mit und ohne zIndex; abgeschlossen ist die Aufgabe, wenn Android-Nutzer verschiedene Bereiche des fokussierten TextInput antippen und den Cursor normal bewegen können.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
android, react-native
Bereich
mobile
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Aktiv
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
48/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.