mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
NativeAnimatedModule: don't restore default values when disconnected nodes in Fabric
Summary: See title. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D22488069 fbshipit-source-id: a0cb2dc65e5ea4befd7921acd194a67840b1498d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
80f13412e5
commit
7bf56e1902
@@ -13,6 +13,8 @@ import com.facebook.react.bridge.JavaOnlyMap;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.bridge.ReadableMapKeySetIterator;
|
||||
import com.facebook.react.bridge.UIManager;
|
||||
import com.facebook.react.uimanager.common.UIManagerType;
|
||||
import com.facebook.react.uimanager.common.ViewUtil;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -69,6 +71,14 @@ import java.util.Map;
|
||||
if (mConnectedViewTag == -1) {
|
||||
return;
|
||||
}
|
||||
// Don't restore default values in Fabric.
|
||||
// In Non-Fabric this had the effect of "restore the value to whatever the value was on the
|
||||
// ShadowNode instead of in the View hierarchy". However, "synchronouslyUpdateViewOnUIThread"
|
||||
// will not have that impact on Fabric, because the FabricUIManager doesn't have access to the
|
||||
// ShadowNode layer.
|
||||
if (ViewUtil.getUIManagerType(mConnectedViewTag) == UIManagerType.FABRIC) {
|
||||
return;
|
||||
}
|
||||
|
||||
ReadableMapKeySetIterator it = mPropMap.keySetIterator();
|
||||
while (it.hasNextKey()) {
|
||||
|
||||
+12
-3
@@ -183,6 +183,15 @@ public class NativeAnimatedNodeTraversalTest {
|
||||
};
|
||||
}
|
||||
});
|
||||
PowerMockito.when(mUIManagerMock.resolveCustomDirectEventName(any(String.class)))
|
||||
.thenAnswer(
|
||||
new Answer<String>() {
|
||||
@Override
|
||||
public String answer(InvocationOnMock invocation) throws Throwable {
|
||||
String arg = invocation.getArguments()[0].toString();
|
||||
return "on" + arg.substring(3);
|
||||
}
|
||||
});
|
||||
mNativeAnimatedNodesManager = new NativeAnimatedNodesManager(mReactApplicationContextMock);
|
||||
}
|
||||
|
||||
@@ -946,7 +955,7 @@ public class NativeAnimatedNodeTraversalTest {
|
||||
|
||||
mNativeAnimatedNodesManager.addAnimatedEventToView(
|
||||
viewTag,
|
||||
"topScroll",
|
||||
"onScroll",
|
||||
JavaOnlyMap.of(
|
||||
"animatedValueTag", 1, "nativeEventPath", JavaOnlyArray.of("contentOffset", "y")));
|
||||
|
||||
@@ -999,7 +1008,7 @@ public class NativeAnimatedNodeTraversalTest {
|
||||
public Object answer(InvocationOnMock invocation) throws Throwable {
|
||||
return MapBuilder.of(
|
||||
"customDirectEventTypes",
|
||||
MapBuilder.of("topScroll", MapBuilder.of("registrationName", "onScroll")));
|
||||
MapBuilder.of("onScroll", MapBuilder.of("registrationName", "onScroll")));
|
||||
}
|
||||
});
|
||||
mNativeAnimatedNodesManager = new NativeAnimatedNodesManager(mReactApplicationContextMock);
|
||||
@@ -1024,7 +1033,7 @@ public class NativeAnimatedNodeTraversalTest {
|
||||
|
||||
@Test
|
||||
public void testRestoreDefaultProps() {
|
||||
int viewTag = 1000;
|
||||
int viewTag = 1001; // restoreDefaultProps not called in Fabric, make sure it's a non-Fabric tag
|
||||
int propsNodeTag = 3;
|
||||
mNativeAnimatedNodesManager.createAnimatedNode(
|
||||
1, JavaOnlyMap.of("type", "value", "value", 1d, "offset", 0d));
|
||||
|
||||
Reference in New Issue
Block a user