Fix initial padding value for TextInput

Summary:
Changelog: [internal]

# Problem

Default padding for TextEdit is top: 26, bottom: 29, left: 10, right: 10 however the default values for LayoutMetrics.contentInsets is {0, 0, 0, 0}.

If you try to construct TextEdit with padding 0, Fabric will drop padding update because padding is already 0, 0, 0, 0.

# Fix
To fix this, I added a special case to `Binding::createUpdatePaddingMountItem`, if the mutation is insert, proceed with updating padding.

Reviewed By: JoshuaGross

Differential Revision: D23731498

fbshipit-source-id: 294ab053e562c05aadf6e743fb6bf12285d50307
This commit is contained in:
Samuel Susla
2020-09-16 11:49:56 -07:00
committed by Facebook GitHub Bot
parent 2103839525
commit 4a6039c635
@@ -428,11 +428,12 @@ local_ref<JMountItem::javaobject> createUpdatePaddingMountItem(
auto newChildShadowView = mutation.newChildShadowView;
if (oldChildShadowView.layoutMetrics.contentInsets ==
newChildShadowView.layoutMetrics.contentInsets) {
newChildShadowView.layoutMetrics.contentInsets &&
mutation.type != ShadowViewMutation::Type::Insert) {
return nullptr;
}
static auto updateLayoutInstruction =
static auto updatePaddingInstruction =
jni::findClassStatic(Binding::UIManagerJavaDescriptor)
->getMethod<alias_ref<JMountItem>(jint, jint, jint, jint, jint)>(
"updatePaddingMountItem");
@@ -446,7 +447,7 @@ local_ref<JMountItem::javaobject> createUpdatePaddingMountItem(
int right = round(contentInsets.right * pointScaleFactor);
int bottom = round(contentInsets.bottom * pointScaleFactor);
return updateLayoutInstruction(
return updatePaddingInstruction(
javaUIManager, newChildShadowView.tag, left, top, right, bottom);
}