Fix setJSResponder Nodes crash

Summary:
Nodes crashed when setJSResponder was called on a virtual (non-View)
node, because a View could not be found using that react tag. The solution is
two fold - first, to figure out the View parent and pass that to
setJSResponder in addition to that of the virtual tag. Secondly, we weren't
mounting views that had animation properties (transform, for example) to
Views, which caused related code to fail.

Reviewed By: sriramramani

Differential Revision: D3301310
This commit is contained in:
Ahmed El-Helw
2016-05-13 16:31:24 -07:00
parent 273c2e539c
commit 96cb8165c8
2 changed files with 11 additions and 1 deletions

View File

@@ -465,10 +465,18 @@ public class FlatUIImplementation extends UIImplementation {
while (node.isVirtual()) {
node = node.getParent();
}
int tag = node.getReactTag();
// if the node in question doesn't mount to a View, find the first parent that does mount to
// a View. without this, we'll crash when we try to set the JSResponder, since part of that
// is to find the parent view and ask it to not intercept touch events.
while (node instanceof FlatShadowNode && !((FlatShadowNode) node).mountsToView()) {
node = node.getParent();
}
FlatUIViewOperationQueue operationsQueue = mStateBuilder.getOperationsQueue();
operationsQueue.enqueueSetJSResponder(
node.getReactTag(),
node == null ? tag : node.getReactTag(),
possiblyVirtualReactTag,
blockNativeResponder);
}