From 9cd8efa89758dbc0b0169cde1aaabdbe0629dbc6 Mon Sep 17 00:00:00 2001 From: Joe Vilches Date: Mon, 7 Apr 2025 14:46:29 -0700 Subject: [PATCH] Expose accessibility order (#50481) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/50481 It's here! kinda...this only works internally right now, so no OSS usage which is explicitly gated to be off. We can't really avoid exposing the types so here we are. Changelog: [Internal] Reviewed By: jorge-cab Differential Revision: D72428425 fbshipit-source-id: 9642e5db46f9bd34ff505b0e37987da52857b6e9 --- .../Libraries/Components/View/ViewAccessibility.js | 7 +++++++ .../__tests__/__snapshots__/public-api-test.js.snap | 1 + .../renderer/components/view/HostPlatformViewProps.cpp | 8 ++++++++ 3 files changed, 16 insertions(+) diff --git a/packages/react-native/Libraries/Components/View/ViewAccessibility.js b/packages/react-native/Libraries/Components/View/ViewAccessibility.js index e7cc4658608..08ba5e0a047 100644 --- a/packages/react-native/Libraries/Components/View/ViewAccessibility.js +++ b/packages/react-native/Libraries/Components/View/ViewAccessibility.js @@ -358,6 +358,13 @@ export type AccessibilityProps = $ReadOnly<{ */ 'aria-label'?: ?Stringish, + /** + * Defines the order in which descendant elements receive accessibility focus. + * The elements in the array represent nativeID values for the respective + * descendant elements. + */ + experimental_accessibilityOrder?: ?Array, + /** * Indicates to accessibility services to treat UI component like a specific role. */ diff --git a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap index f55228581ed..cd234ade9a4 100644 --- a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap +++ b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap @@ -3648,6 +3648,7 @@ export type AccessibilityProps = $ReadOnly<{ accessibilityLabel?: ?Stringish, accessibilityHint?: ?Stringish, \\"aria-label\\"?: ?Stringish, + experimental_accessibilityOrder?: ?Array, accessibilityRole?: ?AccessibilityRole, role?: ?Role, accessibilityState?: ?AccessibilityState, diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewProps.cpp b/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewProps.cpp index 4355fed6c45..f5ee897794e 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewProps.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewProps.cpp @@ -823,6 +823,14 @@ folly::dynamic HostPlatformViewProps::getDiffProps( result["accessibilityLabelledBy"] = accessibilityLabelledByValues; } + if (accessibilityOrder != oldProps->accessibilityOrder) { + auto accessibilityChildrenIds = folly::dynamic::array(); + for (const auto& accessibilityChildId : accessibilityOrder) { + accessibilityChildrenIds.push_back(accessibilityChildId); + } + result["experimental_accessibilityOrder"] = accessibilityChildrenIds; + } + if (accessibilityLiveRegion != oldProps->accessibilityLiveRegion) { switch (accessibilityLiveRegion) { case AccessibilityLiveRegion::Assertive: