From 1f8d824e679caadcdf45029ea4bdbe611a89c6a4 Mon Sep 17 00:00:00 2001 From: Jorge Cabiedes Acosta Date: Thu, 27 Mar 2025 16:02:55 -0700 Subject: [PATCH] Ignore unexisting nativeIDs on accessibilityOrder (#50325) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/50325 axOrderViews is an optimization I came up with so that we could find and queue all the views on a single tree traversal. It initializes the array with the size of the accessibilityOrder array and places each view where its nativeID is. If there is no view corresponding to the nativeID then that axOrderViews element will be null. So to fully ignore nativeIDs that don't correspond to any View we can just filter the nulls Changelog: [Internal] Reviewed By: joevilches Differential Revision: D71977739 fbshipit-source-id: a3f2138eebe06808ce413355df5d9beb2f4ff388 --- .../java/com/facebook/react/uimanager/ReactAxOrderHelper.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAxOrderHelper.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAxOrderHelper.kt index 859239c096b..60f2792e1a3 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAxOrderHelper.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAxOrderHelper.kt @@ -33,14 +33,14 @@ private object ReactAxOrderHelper { } } - val axOrderViews = processAxOrderTree(host, axOrderIdsList, axOrderSet) + val axOrderViews = processAxOrderTree(host, axOrderIdsList, axOrderSet).filterNotNull() // Set up traversal order between views for (i in 0 until axOrderViews.size - 1) { val currentView = axOrderViews[i] val flowToView = axOrderViews[i + 1] - currentView?.setTag(R.id.accessibility_order_flow_to, flowToView) + currentView.setTag(R.id.accessibility_order_flow_to, flowToView) } }