Skip to content

Commit b9bdef6

Browse files
mdvaccameta-codesync[bot]
authored andcommitted
Add comprehensive KDoc documentation to ReactAxOrderHelper (#54395)
Summary: Pull Request resolved: #54395 Added comprehensive KDoc documentation to the ReactAxOrderHelper object and all public methods to improve code readability and developer experience. The ReactAxOrderHelper utility manages accessibility focus order in React Native views by storing/restoring focusability states and building ordered lists of views based on accessibility preferences. This documentation explains the purpose, behavior, and parameters of each method to help developers understand the accessibility ordering implementation. The documentation includes: - Object-level overview explaining the helper's role in managing accessibility order - Detailed method documentation for cleanUpAxOrder(), restoreFocusability(), disableFocusForSubtree(), and buildAxOrderList() - Parameter descriptions with clear explanations of expected inputs - Comprehensive descriptions of what each method does and when to use it changelog: [internal] internal Reviewed By: alanleedev Differential Revision: D86012271 fbshipit-source-id: b1aaa204e23ec9520c97482c7ff264ec4b1c7287
1 parent cf85c1d commit b9bdef6

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAxOrderHelper.kt

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,22 @@ import android.view.View
1111
import android.view.ViewGroup
1212
import com.facebook.react.R
1313

14+
/**
15+
* Helper object for managing accessibility order in React Native views.
16+
*
17+
* This object provides utilities to manage the accessibility focus order of views by storing and
18+
* restoring focusability states, and building ordered lists of views based on accessibility order
19+
* preferences.
20+
*/
1421
public object ReactAxOrderHelper {
22+
/**
23+
* Cleans up accessibility order state from a view and its children.
24+
*
25+
* This method removes stored focusability states and accessibility order parent references from
26+
* the view hierarchy. It recursively processes all children of ViewGroup instances.
27+
*
28+
* @param view The view from which to clean up accessibility order state
29+
*/
1530
@JvmStatic
1631
public fun cleanUpAxOrder(view: View) {
1732
val originalFocusability = view.getTag(R.id.original_focusability) as Boolean?
@@ -31,6 +46,15 @@ public object ReactAxOrderHelper {
3146
}
3247
}
3348

49+
/**
50+
* Restores the original focusability state of a view and its children.
51+
*
52+
* This method traverses the view hierarchy and restores the focusability state that was
53+
* previously saved with the `R.id.original_focusability` tag. This is typically used after
54+
* accessibility order operations are complete to return views to their original state.
55+
*
56+
* @param view The view whose focusability state should be restored
57+
*/
3458
@JvmStatic
3559
public fun restoreFocusability(view: View) {
3660
val originalFocusability = view.getTag(R.id.original_focusability) as Boolean?
@@ -45,6 +69,16 @@ public object ReactAxOrderHelper {
4569
}
4670
}
4771

72+
/**
73+
* Disables focus for all views in the subtree that are not in the accessibility order list.
74+
*
75+
* This method recursively traverses the view hierarchy and disables focusability for views that
76+
* are not included in the provided accessibility order list. It stores the original focusability
77+
* state before modifying it, allowing for later restoration.
78+
*
79+
* @param view The root view of the subtree to process
80+
* @param axOrderList The list of native IDs that should maintain their focusability
81+
*/
4882
public fun disableFocusForSubtree(view: View, axOrderList: MutableList<*>) {
4983
if (!axOrderList.contains(view.getTag(R.id.view_tag_native_id))) {
5084
if (view.getTag(R.id.original_focusability) == null) {
@@ -60,6 +94,19 @@ public object ReactAxOrderHelper {
6094
}
6195
}
6296

97+
/**
98+
* Builds an ordered list of views based on accessibility order preferences.
99+
*
100+
* This method recursively traverses the view hierarchy starting from the given view, looking for
101+
* views whose native IDs match entries in the accessibility order list. When matches are found,
102+
* views are placed in the result array at positions corresponding to their position in the
103+
* accessibility order list. This method also tags each view with its accessibility order parent.
104+
*
105+
* @param view The current view being processed in the hierarchy traversal
106+
* @param parent The parent view that defines the accessibility order context
107+
* @param axOrderList The list of native IDs defining the desired accessibility order
108+
* @param result The output array where views are placed according to their order in axOrderList
109+
*/
63110
public fun buildAxOrderList(
64111
view: View,
65112
parent: View,

0 commit comments

Comments
 (0)