From 1e453860d0a1e570bf5ecce128a140f455cb87ce Mon Sep 17 00:00:00 2001 From: David Vacca Date: Sat, 13 Jun 2020 22:18:06 -0700 Subject: [PATCH] Ensure that layout events contain the correct padding information Summary: This diff changes the order of execution for the "updatePadding" mount item Padding mountItems must be executed before layout props are updated in the view. This is necessary to ensure that events (resulting from layout changes) are dispatched with the correct padding information. This fixes a 'flickering' bug in Marketplace Vehicles (see test plan) changelog:[internal] Reviewed By: JoshuaGross, sammy-SC Differential Revision: D22034850 fbshipit-source-id: 222fa9412dd01f65a1a034f53e1eb0e7b774ec1f --- .../com/facebook/react/fabric/jni/Binding.cpp | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 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 156cac88d5b..7eb300c1924 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 @@ -762,17 +762,21 @@ void Binding::schedulerDidFinishTransaction( createUpdateStateMountItem(localJavaUIManager, mutation); } - auto updateLayoutMountItem = - createUpdateLayoutMountItem(localJavaUIManager, mutation); - if (updateLayoutMountItem) { - mountItems[position++] = updateLayoutMountItem; - } - + // Padding: padding mountItems must be executed before layout props + // are updated in the view. This is necessary to ensure that events + // (resulting from layout changes) are dispatched with the correct + // padding information. auto updatePaddingMountItem = createUpdatePaddingMountItem(localJavaUIManager, mutation); if (updatePaddingMountItem) { mountItems[position++] = updatePaddingMountItem; } + + auto updateLayoutMountItem = + createUpdateLayoutMountItem(localJavaUIManager, mutation); + if (updateLayoutMountItem) { + mountItems[position++] = updateLayoutMountItem; + } } if (mutation.oldChildShadowView.eventEmitter != @@ -805,19 +809,22 @@ void Binding::schedulerDidFinishTransaction( createUpdateStateMountItem(localJavaUIManager, mutation); } + // Padding: padding mountItems must be executed before layout props + // are updated in the view. This is necessary to ensure that events + // (resulting from layout changes) are dispatched with the correct + // padding information. + auto updatePaddingMountItem = + createUpdatePaddingMountItem(localJavaUIManager, mutation); + if (updatePaddingMountItem) { + mountItems[position++] = updatePaddingMountItem; + } + // Layout auto updateLayoutMountItem = createUpdateLayoutMountItem(localJavaUIManager, mutation); if (updateLayoutMountItem) { mountItems[position++] = updateLayoutMountItem; } - - // Padding - auto updatePaddingMountItem = - createUpdatePaddingMountItem(localJavaUIManager, mutation); - if (updatePaddingMountItem) { - mountItems[position++] = updatePaddingMountItem; - } } // EventEmitter