From 4a6039c6359ba70f5cca57ceff26c06f2a0de76b Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Wed, 16 Sep 2020 11:46:47 -0700 Subject: [PATCH] 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 --- .../main/java/com/facebook/react/fabric/jni/Binding.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp index 9fb51e79fd7..390166bfd7f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp @@ -428,11 +428,12 @@ local_ref 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(jint, jint, jint, jint, jint)>( "updatePaddingMountItem"); @@ -446,7 +447,7 @@ local_ref createUpdatePaddingMountItem( int right = round(contentInsets.right * pointScaleFactor); int bottom = round(contentInsets.bottom * pointScaleFactor); - return updateLayoutInstruction( + return updatePaddingInstruction( javaUIManager, newChildShadowView.tag, left, top, right, bottom); }