Skip to content

Commit

Permalink
textInput: Fix placeholder is not completely visible on Android. (#20337
Browse files Browse the repository at this point in the history
)

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 8402232
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ public final class ReactTextInputLocalData {
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();
Expand All @@ -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.