diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java index 3bc192c9ad..11bb030ff3 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java @@ -513,6 +513,18 @@ public class UIImplementation { mOperationsQueue.enqueueFindTargetForTouch(reactTag, targetX, targetY, callback); } + /** Check if the first shadow node is the descendant of the second shadow node */ + public void viewIsDescendantOf( + final int reactTag, final int ancestorReactTag, final Callback callback) { + ReactShadowNode node = mShadowNodeRegistry.getNode(reactTag); + ReactShadowNode ancestorNode = mShadowNodeRegistry.getNode(ancestorReactTag); + if (node == null || ancestorNode == null) { + callback.invoke(false); + return; + } + callback.invoke(node.isDescendantOf(ancestorNode)); + } + /** * Determines the location on screen, width, and height of the given view relative to the root * view and returns the values via an async callback. diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java index d125cb5dfc..f91d281c42 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java @@ -629,6 +629,13 @@ public class UIManagerModule extends ReactContextBaseJavaModule callback); } + /** Check if the first shadow node is the descendant of the second shadow node */ + @ReactMethod + public void viewIsDescendantOf( + final int reactTag, final int ancestorReactTag, final Callback callback) { + mUIImplementation.viewIsDescendantOf(reactTag, ancestorReactTag, callback); + } + @Override @ReactMethod public void setJSResponder(int reactTag, boolean blockNativeResponder) {