react / react/react-native

🐛 Android: Cursor jumps to right when clearing centered TextInput

オープン
#55,457 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Component: TextInput Needs: Attention Needs: Repro Platform: Android
主要言語
C++
スター
127k
フォーク
25.3k
平均マージ
1日 23時間
マージ済み PR(30日)
4

説明

Description

When using a TextInput with textAlign: "center" on Android, clearing the input causes the cursor to move to the right end of the input instead of staying centered.

This does not happen on iOS — iOS behaves correctly.

This issue makes centered numeric or OTP-style inputs feel broken on Android.

Steps to reproduce

1)Render a TextInput with textAlign: "center"
2)Type any value
3)Clear the value (backspace or programmatically)
4)Observe cursor position

`import React, { useState } from "react";
import { View, TextInput, StyleSheet } from "react-native";

export default function App() {
const [value, setValue] = useState("");

return (



);
}

const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
padding: 20,
},
input: {
borderWidth: 1,
height: 48,
fontSize: 18,
textAlign: "center",
},
});
`

React Native Version

0.83.0

Affected Platforms

Runtime - Android

Output of npx @react-native-community/cli info
N/A
Stacktrace or Logs
N/A
MANDATORY Reproducer

https://reactnative.dev/docs/textinput

Screenshots and Videos

https://github.com/user-attachments/assets/20586de1-a4fc-40d5-8495-2d6cc29ace5f

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

React Native ドキュメントにある必須の TextInput 再現例から始め、textAlign を center に設定した状態で Android 上の挙動を再現します。制御された入力テキストをクリアするときに関係する Android の TextInput の挙動を追跡します。backspace またはプログラムによってクリアした後もカーソルが中央に留まり、正しい iOS の挙動を変更しないことを完了条件とします。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
react-native
領域
mobile
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
58/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。