Skip to content
Permalink
Browse files

Fix placeholder clipping issue

Summary:
Problem: The first ReactTextInputShadowNode layout  calculation didn't consider the placeholder. When the layout with placeholder was actually being measured, its height was constraint by the previously calculated height, causing long placeholder content to be clipped.
Fix: Access the placeholder property in ReactTextInputShadowNode, set the dummyEditText's hint with placeholder before ReactTextInputShadowNode's first measurement.

Reviewed By: mdvacca

Differential Revision: D8903108

fbshipit-source-id: 8f3e518d0395ac875807f9ea989a0b5bbe4b2a26
  • Loading branch information...
Jiaqi Wu authored and facebook-github-bot committed Jul 20, 2018
1 parent de57327 commit 86f24ccf71f4c41904838c8c7e13268c300fd745
@@ -41,9 +41,11 @@
private @Nullable ReactTextInputLocalData mLocalData;

@VisibleForTesting public static final String PROP_TEXT = "text";
@VisibleForTesting public static final String PROP_PLACEHOLDER = "placeholder";

// Represents the {@code text} property only, not possible nested content.
private @Nullable String mText = null;
private @Nullable String mPlaceholder = null;

public ReactTextInputShadowNode() {
mTextBreakStrategy = (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) ?
@@ -148,8 +150,9 @@ public long measure(
}
}


editText.measure(
// make sure the placeholder content is also being measured
editText.setHint(getPlaceholder());
editText.measure(
MeasureUtil.getMeasureSpec(width, widthMode),
MeasureUtil.getMeasureSpec(height, heightMode));

@@ -193,6 +196,16 @@ public void setText(@Nullable String text) {
return mText;
}

@ReactProp(name = PROP_PLACEHOLDER)
public void setPlaceholder(@Nullable String placeholder) {
mPlaceholder = placeholder;
markUpdated();
}

public @Nullable String getPlaceholder() {
return mPlaceholder;
}

@Override
public void setTextBreakStrategy(@Nullable String textBreakStrategy) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {

0 comments on commit 86f24cc

Please sign in to comment.
You can’t perform that action at this time.