Permalink
Browse files

textInput: Fix placeholder is not completely visible on Android. (#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: #20337

Differential Revision: D8950051

Pulled By: mdvacca

fbshipit-source-id: a583a48c90ecd55d8dd8c6f4eef829608b2a6079
  • Loading branch information...
jainkuniya authored and facebook-github-bot committed Jul 23, 2018
1 parent e592d6f commit 84022321c437e597660ecd8a773e51bdf8855f4e
@@ -21,11 +21,13 @@
private final int mMaxLines;
private final int mInputType;
private final int mBreakStrategy;
private final CharSequence mPlaceholder;
public ReactTextInputLocalData(EditText editText) {
mText = new SpannableStringBuilder(editText.getText());
mTextSize = editText.getTextSize();
mInputType = editText.getInputType();
mPlaceholder = editText.getHint();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
mMinLines = editText.getMinLines();
@@ -48,8 +50,9 @@ public void apply(EditText editText) {
editText.setMinLines(mMinLines);
editText.setMaxLines(mMaxLines);
editText.setInputType(mInputType);
editText.setHint(mPlaceholder);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
editText.setBreakStrategy(mBreakStrategy);
}
}
}
}

0 comments on commit 8402232

Please sign in to comment.