From 57c40d9a6f5a901cf108b72ab18f4bae9fc246e2 Mon Sep 17 00:00:00 2001 From: Dave Miller Date: Wed, 27 Apr 2016 10:15:47 -0700 Subject: [PATCH] Fix crash caused by accessibility being turned on and using a Modal Summary: When the ModalHostView is added as a child of whatever view holds it, if accessibility is turned on, Android will walk up to the root and then walk all children of the child and verify that they are indeed children of the root. Since ModalHostView actually adds its children to a new ReactDialogViewGroup which has the Dialog as a parent, there is a disagreement about the tree deep in the bowels of View when it performs that walk. The trick is to stop from adding the children of the ModalHostView when walking for accessibility. The accessibility of those children views are properly handled by the hosting Dialog. Reviewed By: andreicoman11 Differential Revision: D3230033 fb-gh-sync-id: 1e5ac334c996b1d5f50c75ded60805d8b871477a fbshipit-source-id: 1e5ac334c996b1d5f50c75ded60805d8b871477a --- .../facebook/react/views/modal/ReactModalHostView.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java b/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java index ac52e282d2d..17d583c197c 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java @@ -11,6 +11,8 @@ package com.facebook.react.views.modal; import javax.annotation.Nullable; +import java.util.ArrayList; + import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; @@ -99,6 +101,12 @@ public class ReactModalHostView extends ViewGroup { mHostView.removeView(child); } + @Override + public void addChildrenForAccessibility(ArrayList outChildren) { + // Explicitly override this to prevent accessibility events being passed down to children + // Those will be handled by the mHostView which lives in the dialog + } + public void dismiss() { if (mDialog != null) { mDialog.dismiss();