-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent text behavior in TextInput between iOS and Android #14845
Comments
This seemed similar to #12322 but I felt this was different since this is about ellipsizing and the difference between iOS and Android in which part of the text displays as opposed to two different TextInputs on Android displaying differently. |
This comment has been minimized.
This comment has been minimized.
Yes, I can confirm this is still happening on the latest version of React Native. This should be re-opened |
v0.53 or v0.54? |
Oh, my mistake. It is happening in v0.52 |
I can't confirm whether it is or isn't happening in v0.53 or v0.54 |
0.54.2 still having the same issue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I can confirm that this is happening on both RN52 and RN54. In Android, this essentially forces the user to read from right to left. Note to Google, in English, we start reading from left to right. In English, we don't start at the end of a sentence and then work our way backwards. This isn't Arabic or Hebrew. I'm baffled why Android would have this as their default... this shouldn't be something the RN team should have to override. I get that Android serves an international audience, but the default should support the more/most common languages' settings. |
Hi @quadsurf, <?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="@string/app_name"
android:textAppearance="?android:textAppearanceLarge" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:singleLine="true"
android:text="@string/app_name"
android:textAppearance="?android:textAppearanceLarge" />
</LinearLayout>
</ScrollView> |
0.57.1 still having this issue. Very sad behavior if we have a long text in Android. |
This comment has been minimized.
This comment has been minimized.
On RN 61.5, setting this prop: selection={{
start: 0,
}} will do the good display (if not focused), but on focus, the cursor will be at start instead of at end. Not so sexy but it could maybe work. |
Any news on this? |
Dont we have solution for this yet? |
This is still an issue in 0.61.5, is any news on this? |
I am having this issue as well on "react-native": "0.61.5" |
@Override
public void setSelection(int start, int end) {
super.setSelection(start, end);
} by settings the cursor position, you automatically scroll the I know how to solve this and I have a pr ready for it, but I want to quickly look in the root issue of this problem. Why are we scrolling to the end of the I am working on this issue |
As this issue has 28 likes I'll give it special attention. I reviewed carefully the source-code and I believe this is more of a feature request then a bug. iOS and Android have different behaviour and the ReactNative developer has no access to a This is the example I used to test this functionality, which clearly shows how placeholder etc.. do not change the import React, { Component } from 'react';
import { Button, TextInput, ScrollView, StyleSheet } from 'react-native';
export default class App extends Component {
state = { text: null }
setText = () => {
this.setState({ text: "A really long string of text that extends far beyond the end of the TextInput" });
}
render() {
return (
<ScrollView style={styles.container}>
<TextInput
value={this.state.text}
placeholder="A really long string of text that extends far beyond the end of the TextInput"
style={styles.input}
/>
<Button
title="Set Text"
onPress={this.setText} />
</ScrollView>
);
}
}
const styles = StyleSheet.create({
container: {
},
input: {
height: 40,
textAlign: "left",
},
}); It is not easy pull request to add
One of the many places where the react-native/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js Lines 545 to 547 in 02b8e67
Seems that they all use
Sending through the bridge react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js Lines 21031 to 21056 in 02b8e67
I believe the only acceptable solution to this problem would be adding |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions. |
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information. |
Still running into this issue on 0.63.3, can this be re-opened? |
selection={{
start: 0,
}} This fixes the head-of-the-string-getting-chopped issue, but still no ellipsis... |
This issue is still going strong in |
still going |
still stuck on this in 2021! Any update on this??? |
Not sure there is any development going on in core react native these days. Does Facebook even use it internally? |
See on their Documentation the IOS version is still messed up |
Use textAlign:'auto', it should work for you |
Same issue, persists in RN v0.70.0. May be any update? Proposed solutions don't work. |
Same issue RN v0.70.6. |
Why this issue hasn't been solved yet ??? Its been more than 6 years |
it's been 7 already.. |
Is this a bug report?
Yes
Have you read the Bugs section of the Contributing to React Native Guide?
Yes
Environment
react-native -v
:(edit: it reproduces in 0.54.2 according to the comments -@hramos)
node -v
:v7.7.2
npm -v
:4.1.2
yarn --version
(if you use Yarn):N/A
Then, specify:
Steps to Reproduce
value
to a string that will render larger than the width of the text viewExpected Behavior
Both iOS and Android should exhibit the same behavior and display the beginning of the text when unfocused.
Ideally, the ellipsis should also be an optional parameter to display when unfocused on both Android and iOS.
Actual Behavior
iOS displays the beginning of the text, ellipsizing the remaining text before truncating.
Android displays the end of the text with no ellipsis at the beginning.
Reproducible Demo
Example project: https://snack.expo.io/S1Lty1oN-
To view the issue, launch the example project and preview in Android. Then preview in iOS. Note the differences between where ellipsis show and which part of the sentence displays.
The text was updated successfully, but these errors were encountered: