mirror of
https://github.com/status-im/react-native.git
synced 2025-02-26 16:10:58 +00:00
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
This commit is contained in:
parent
de573277bf
commit
86f24ccf71
@ -41,9 +41,11 @@ public class ReactTextInputShadowNode extends ReactBaseTextShadowNode
|
||||
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 class ReactTextInputShadowNode extends ReactBaseTextShadowNode
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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 class ReactTextInputShadowNode extends ReactBaseTextShadowNode
|
||||
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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user