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
This commit is contained in:
Jorge Cabiedes Acosta
2025-03-27 16:02:55 -07:00
committed by Facebook GitHub Bot
parent 05fe502821
commit 1f8d824e67
@@ -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)
}
}