Default TextInput padding to 0 in Fabric

Summary:
In D36345402 (56e9aa369f) 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
This commit is contained in:
Pieter De Baets 2022-05-25 03:48:32 -07:00 коммит произвёл Facebook GitHub Bot
Родитель 38b70653b2
Коммит c02b5b8ad4
1 изменённых файлов: 10 добавлений и 1 удалений

Просмотреть файл

@ -1273,7 +1273,16 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
FLog.e(TAG, "updateState: [" + view.getId() + "]");
}
view.getFabricViewStateManager().setStateWrapper(stateWrapper);
FabricViewStateManager stateManager = view.getFabricViewStateManager();
if (!stateManager.hasStateWrapper()) {
// HACK: In Fabric, we assume all components start off with zero padding, which is
// not true for TextInput components. We expose the theme's default padding via
// AndroidTextInputComponentDescriptor, which will be applied later though setPadding.
// TODO T58784068: move this constructor once Fabric is shipped
view.setPadding(0, 0, 0, 0);
}
stateManager.setStateWrapper(stateWrapper);
ReadableNativeMap state = stateWrapper.getStateData();
if (state == null) {