Skip to content

Commit c02b5b8

Browse files
javachefacebook-github-bot
authored andcommitted
Default TextInput padding to 0 in Fabric
Summary: In D36345402 (56e9aa3) I changed the behaviour for mount items to be skipped if they were just setting zero values. AndroidTextInput is the only component that I'm aware of that has non-zero padding by default, and we account for this when creating the native shadow node. This optimization broken TextInput use-cases that explicitly request zero-padding, since we end up ignoring it. To keep this optimization, explicitly init ReactTextInput's padding to 0, but only in Fabric. `updateState` was the closest thing I could find to a Fabric-only callback, once it's fully rolled out, we can also move this to the constructor. Changelog: [Internal] Reviewed By: JoshuaGross Differential Revision: D36545775 fbshipit-source-id: 07bb96032c69d7e350980b0b975e637b66c307ed
1 parent 38b7065 commit c02b5b8

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,16 @@ public Object updateState(
12731273
FLog.e(TAG, "updateState: [" + view.getId() + "]");
12741274
}
12751275

1276-
view.getFabricViewStateManager().setStateWrapper(stateWrapper);
1276+
FabricViewStateManager stateManager = view.getFabricViewStateManager();
1277+
if (!stateManager.hasStateWrapper()) {
1278+
// HACK: In Fabric, we assume all components start off with zero padding, which is
1279+
// not true for TextInput components. We expose the theme's default padding via
1280+
// AndroidTextInputComponentDescriptor, which will be applied later though setPadding.
1281+
// TODO T58784068: move this constructor once Fabric is shipped
1282+
view.setPadding(0, 0, 0, 0);
1283+
}
1284+
1285+
stateManager.setStateWrapper(stateWrapper);
12771286

12781287
ReadableNativeMap state = stateWrapper.getStateData();
12791288
if (state == null) {

0 commit comments

Comments
 (0)