Skip to content

Commit 8402232

Browse files
jainkuniyafacebook-github-bot
authored andcommitted
textInput: Fix placeholder is not completely visible on Android. (facebook#20337)
Summary: On Android, placeholder of TextInput is not completely visible. TextInput had some default fixed width. On iOS it is perfectly visible. This commit makes it consistent on both the platforms. Before: https://user-images.githubusercontent.com/39303760/43045649-54cb45e8-8dda-11e8-9935-059ad8ee9def.png After: https://user-images.githubusercontent.com/39303760/43045650-54fb9428-8dda-11e8-88b8-176839d6c0a7.png Testing code: https://github.com/jainkuniya/TestTextInput/blob/a0a6fbb491e979fe7cc9d0a580d67790b3481eb8/App.js Clone code from https://github.com/jainkuniya/TestTextInput/blob/a0a6fbb491e979fe7cc9d0a580d67790b3481eb8/App.js and test on Android with and without this commit. Before: https://user-images.githubusercontent.com/39303760/43045649-54cb45e8-8dda-11e8-9935-059ad8ee9def.png After: https://user-images.githubusercontent.com/39303760/43045650-54fb9428-8dda-11e8-88b8-176839d6c0a7.png [ANDROID] [BUGFIX] [TextInput] - Fix placeholder is not completely visible on Android. Pull Request resolved: facebook#20337 Differential Revision: D8950051 Pulled By: mdvacca fbshipit-source-id: a583a48c90ecd55d8dd8c6f4eef829608b2a6079
1 parent e592d6f commit 8402232

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputLocalData.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ public final class ReactTextInputLocalData {
2121
private final int mMaxLines;
2222
private final int mInputType;
2323
private final int mBreakStrategy;
24+
private final CharSequence mPlaceholder;
2425

2526
public ReactTextInputLocalData(EditText editText) {
2627
mText = new SpannableStringBuilder(editText.getText());
2728
mTextSize = editText.getTextSize();
2829
mInputType = editText.getInputType();
30+
mPlaceholder = editText.getHint();
2931

3032
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
3133
mMinLines = editText.getMinLines();
@@ -48,8 +50,9 @@ public void apply(EditText editText) {
4850
editText.setMinLines(mMinLines);
4951
editText.setMaxLines(mMaxLines);
5052
editText.setInputType(mInputType);
53+
editText.setHint(mPlaceholder);
5154
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
5255
editText.setBreakStrategy(mBreakStrategy);
5356
}
5457
}
55-
}
58+
}

0 commit comments

Comments
 (0)