Permalink
Browse files

Fix TextInput's initial layout measurements

Reviewed By: mdvacca

Differential Revision: D7732819

fbshipit-source-id: 0ca4e5643d2cfefe304d7f189474a671c4bcb31e
  • Loading branch information...
ayc1 authored and facebook-github-bot committed May 30, 2018
1 parent 5fc42f3 commit c6b4f9f2ce59bc757d9e211f46294faa03df55c6
@@ -9,16 +9,19 @@
import android.os.Build;
import android.text.Layout;
import android.util.TypedValue;
import android.view.ViewGroup;
import android.widget.EditText;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
import com.facebook.react.common.annotations.VisibleForTesting;
import com.facebook.react.uimanager.LayoutShadowNode;
import com.facebook.react.uimanager.PixelUtil;
import com.facebook.react.uimanager.ReactShadowNodeImpl;
import com.facebook.react.uimanager.Spacing;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.UIViewOperationQueue;
import com.facebook.react.uimanager.ViewDefaults;
import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.views.text.ReactBaseTextShadowNode;
import com.facebook.react.views.text.ReactTextUpdate;
@@ -127,12 +130,24 @@ public long measure(
// measure() should never be called before setThemedContext()
EditText editText = Assertions.assertNotNull(mDummyEditText);
if (mLocalData == null) {
// No local data, no intrinsic size.
return YogaMeasureOutput.make(0, 0);
if (mLocalData != null) {
mLocalData.apply(editText);
} else {
editText.setTextSize(
TypedValue.COMPLEX_UNIT_PX,
mFontSize == UNSET ?
(int) Math.ceil(PixelUtil.toPixelFromSP(ViewDefaults.FONT_SIZE_SP)) : mFontSize);
if (mNumberOfLines != UNSET) {
editText.setLines(mNumberOfLines);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
editText.getBreakStrategy() != mTextBreakStrategy) {
editText.setBreakStrategy(mTextBreakStrategy);
}
}
mLocalData.apply(editText);
editText.measure(
MeasureUtil.getMeasureSpec(width, widthMode),

0 comments on commit c6b4f9f

Please sign in to comment.