TextInput: ViewManager shouldn't reset EditText padding when none is set

Summary:
UpdateLocalData and UpdateState return an `extra data` object, which in the case of TextInput contains padding. In Paper, the padding was always set on this object; in Fabric, it generally is not. However, the ViewManager was unconditionally setting the padding on the view, regardless of whether or not padding was set. We just check the padding values before setting now. This fixes an issue where the padding would be reset when the user started typing in Fabric.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D18875261

fbshipit-source-id: d7cb87c07f47ab522e32cd34a4ca6ed5fea2e832
This commit is contained in:
Joshua Gross
2019-12-08 18:21:22 -08:00
committed by Facebook Github Bot
parent b1f2c1e2c5
commit 9bb042fe58
@@ -254,11 +254,21 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
if (extraData instanceof ReactTextUpdate) {
ReactTextUpdate update = (ReactTextUpdate) extraData;
view.setPadding(
(int) update.getPaddingLeft(),
(int) update.getPaddingTop(),
(int) update.getPaddingRight(),
(int) update.getPaddingBottom());
// TODO T58784068: delete this block of code, these are always unset in Fabric
int paddingLeft = (int) update.getPaddingLeft();
int paddingTop = (int) update.getPaddingTop();
int paddingRight = (int) update.getPaddingRight();
int paddingBottom = (int) update.getPaddingBottom();
if (paddingLeft != UNSET
|| paddingTop != UNSET
|| paddingRight != UNSET
|| paddingBottom != UNSET) {
view.setPadding(
paddingLeft != UNSET ? paddingLeft : view.getPaddingLeft(),
paddingTop != UNSET ? paddingTop : view.getPaddingTop(),
paddingRight != UNSET ? paddingRight : view.getPaddingRight(),
paddingBottom != UNSET ? paddingBottom : view.getPaddingBottom());
}
if (update.containsImages()) {
Spannable spannable = update.getText();