react / react/react-native

🐛 Android: Cursor jumps to right when clearing centered TextInput

Open
#55,457 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Component: TextInput Needs: Attention Needs: Repro Platform: Android
Dominant language
C++
Stars
127k
Forks
25.3k
Avg merge
1d 23h
Merged PRs (30d)
4

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the mandatory TextInput reproducer in the React Native documentation and reproduce the behavior on Android with textAlign set to center. Trace the Android TextInput behavior involved in clearing controlled input text. Done means the cursor remains centered after clearing by backspace or programmatically, without changing the correct iOS behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
react-native
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.