Skip to content

Commit 9bb042f

Browse files
JoshuaGrossfacebook-github-bot
authored andcommitted
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
1 parent b1f2c1e commit 9bb042f

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,21 @@ public void updateExtraData(ReactEditText view, Object extraData) {
254254
if (extraData instanceof ReactTextUpdate) {
255255
ReactTextUpdate update = (ReactTextUpdate) extraData;
256256

257-
view.setPadding(
258-
(int) update.getPaddingLeft(),
259-
(int) update.getPaddingTop(),
260-
(int) update.getPaddingRight(),
261-
(int) update.getPaddingBottom());
257+
// TODO T58784068: delete this block of code, these are always unset in Fabric
258+
int paddingLeft = (int) update.getPaddingLeft();
259+
int paddingTop = (int) update.getPaddingTop();
260+
int paddingRight = (int) update.getPaddingRight();
261+
int paddingBottom = (int) update.getPaddingBottom();
262+
if (paddingLeft != UNSET
263+
|| paddingTop != UNSET
264+
|| paddingRight != UNSET
265+
|| paddingBottom != UNSET) {
266+
view.setPadding(
267+
paddingLeft != UNSET ? paddingLeft : view.getPaddingLeft(),
268+
paddingTop != UNSET ? paddingTop : view.getPaddingTop(),
269+
paddingRight != UNSET ? paddingRight : view.getPaddingRight(),
270+
paddingBottom != UNSET ? paddingBottom : view.getPaddingBottom());
271+
}
262272

263273
if (update.containsImages()) {
264274
Spannable spannable = update.getText();

0 commit comments

Comments
 (0)