You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
🐛 Android: Cursor jumps to right when clearing centered TextInput #55457
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("");
Missing reproducer: We could not detect a reproducible example in your issue report. Reproducers are mandatory and we can accept only one of those as a valid reproducer:
For majority of bugs: send us a Pull Request with the RNTesterPlayground.js edited to reproduce your bug.
The bug is in maybeSetText() in ReactEditText.kt. When the incoming text has length 0, the code does: if (reactTextUpdate.text.length == 0) { text = null } This call to setText(null) resets the EditText state completely. The comment in the code explains why: on some devices, buggy keyboards don't clear their composing text when the content is programmatically cleared, so setting null forces the composing text to be dismissed. The side effect is that after setText(null), Android places the cursor at its default position, which for a centered EditText does not end up visually centered. Adding an explicit setSelection(0) after the text = null line should put the cursor back at the known empty position, which Android then renders in the center because the gravity is still CENTER_HORIZONTAL. The relevant section in ReactEditText.kt (around line 686) would become:
if (reactTextUpdate.text.length ==0) {
text =null
setSelection(0)
}
This is safe because selectionStart and selectionEnd are both 0 on an empty string anyway. The existing maybeSetSelection() method could also be used here if the broader selection-state machinery needs to be informed.
Activity
react-native-bot commentedon Feb 6, 2026
Warning
Missing reproducer: We could not detect a reproducible example in your issue report. Reproducers are mandatory and we can accept only one of those as a valid reproducer:
You can read more about about it on our website: How to report a bug.
DevarajuluR commentedon Feb 7, 2026
here is the reproducible snack
Textinput issue
ishaquehassan commentedon Feb 27, 2026
The bug is in
maybeSetText()inReactEditText.kt. When the incoming text has length 0, the code does:if (reactTextUpdate.text.length == 0) { text = null }This call tosetText(null)resets theEditTextstate completely. The comment in the code explains why: on some devices, buggy keyboards don't clear their composing text when the content is programmatically cleared, so setting null forces the composing text to be dismissed. The side effect is that aftersetText(null), Android places the cursor at its default position, which for a centeredEditTextdoes not end up visually centered. Adding an explicitsetSelection(0)after thetext = nullline should put the cursor back at the known empty position, which Android then renders in the center because the gravity is stillCENTER_HORIZONTAL. The relevant section inReactEditText.kt(around line 686) would become:This is safe because
selectionStartandselectionEndare both 0 on an empty string anyway. The existingmaybeSetSelection()method could also be used here if the broader selection-state machinery needs to be informed.HarshitMadhav commentedon Apr 26, 2026
Hi @ishaquehassan @DevarajuluR I have raised a fix for this PR here
#56615
fix(android): preserve cursor position when centered TextInput is cle…
fix(android): preserve cursor position when centered TextInput is cle…
HarshitMadhav commentedon May 26, 2026
@react-native-bot Please review this #56615 for this fix