File tree 11 files changed +47
-1
lines changed
src/main/java/com/facebook/react/uimanager
ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view
11 files changed +47
-1
lines changed Original file line number Diff line number Diff line change @@ -273,6 +273,13 @@ export interface AccessibilityPropsAndroid {
273
273
| 'no'
274
274
| 'no-hide-descendants'
275
275
| undefined ;
276
+
277
+ /**
278
+ * Enables the view to be screen reader focusable, not keyboard focusable.
279
+ *
280
+ * @platform android
281
+ */
282
+ screenReaderFocusable ?: boolean | undefined ;
276
283
}
277
284
278
285
export interface AccessibilityPropsIOS {
Original file line number Diff line number Diff line change @@ -258,6 +258,14 @@ export type AccessibilityPropsAndroid = $ReadOnly<{
258
258
* See https://reactnative.dev/docs/view#importantforaccessibility
259
259
*/
260
260
importantForAccessibility ?: ?( 'auto' | 'yes' | 'no' | 'no-hide-descendants' ) ,
261
+
262
+ /**
263
+ * Enables the view to be screen reader focusable, not keyboard focusable. This has lower priority
264
+ * than focusable or accessible props.
265
+ *
266
+ * @platform android
267
+ */
268
+ screenReaderFocusable ?: boolean ,
261
269
} > ;
262
270
263
271
export type AccessibilityPropsIOS = $ReadOnly < {
Original file line number Diff line number Diff line change @@ -205,6 +205,7 @@ const validAttributesForNonEventProps = {
205
205
accessibilityValue : true ,
206
206
experimental_accessibilityOrder : true ,
207
207
importantForAccessibility : true ,
208
+ screenReaderFocusable : true ,
208
209
role : true ,
209
210
rotation : true ,
210
211
scaleX : true ,
Original file line number Diff line number Diff line change @@ -3642,6 +3642,7 @@ export type AccessibilityPropsAndroid = $ReadOnly<{
3642
3642
accessibilityLiveRegion?: ?(\\"none\\" | \\"polite\\" | \\"assertive\\"),
3643
3643
\\"aria-live\\"?: ?(\\"polite\\" | \\"assertive\\" | \\"off\\"),
3644
3644
importantForAccessibility?: ?(\\"auto\\" | \\"yes\\" | \\"no\\" | \\"no-hide-descendants\\"),
3645
+ screenReaderFocusable?: boolean,
3645
3646
}>;
3646
3647
export type AccessibilityPropsIOS = $ReadOnly<{
3647
3648
accessibilityIgnoresInvertColors?: ?boolean,
Original file line number Diff line number Diff line change @@ -3524,6 +3524,7 @@ public abstract class com/facebook/react/uimanager/BaseViewManager : com/faceboo
3524
3524
public fun setRotation (Landroid/view/View;F)V
3525
3525
public fun setScaleX (Landroid/view/View;F)V
3526
3526
public fun setScaleY (Landroid/view/View;F)V
3527
+ public fun setScreenReaderFocusable (Landroid/view/View;Ljava/lang/Boolean;)V
3527
3528
public fun setShadowColor (Landroid/view/View;I)V
3528
3529
public fun setShouldBlockNativeResponder (Landroid/view/View;Z)V
3529
3530
public fun setStartShouldSetResponder (Landroid/view/View;Z)V
@@ -4896,6 +4897,7 @@ public final class com/facebook/react/uimanager/ViewProps {
4896
4897
public static final field ROW_GAP Ljava/lang/String;
4897
4898
public static final field SCALE_X Ljava/lang/String;
4898
4899
public static final field SCALE_Y Ljava/lang/String;
4900
+ public static final field SCREEN_READER_FOCUSABLE Ljava/lang/String;
4899
4901
public static final field SCROLL Ljava/lang/String;
4900
4902
public static final field SHADOW_COLOR Ljava/lang/String;
4901
4903
public static final field START Ljava/lang/String;
Original file line number Diff line number Diff line change @@ -513,6 +513,17 @@ public void setImportantForAccessibility(
513
513
}
514
514
}
515
515
516
+ @ ReactProp (name = ViewProps .SCREEN_READER_FOCUSABLE )
517
+ public void setScreenReaderFocusable (@ NonNull T view , boolean screenReaderFocusable ) {
518
+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .P ) {
519
+ if (screenReaderFocusable != null ) {
520
+ view .setScreenReaderFocusable (screenReaderFocusable );
521
+ } else {
522
+ view .setScreenReaderFocusable (false );
523
+ }
524
+ }
525
+ }
526
+
516
527
@ ReactProp (name = ViewProps .ROLE )
517
528
public void setRole (@ NonNull T view , @ Nullable String role ) {
518
529
if (role == null ) {
Original file line number Diff line number Diff line change @@ -82,6 +82,9 @@ public abstract class BaseViewManagerDelegate<
82
82
ViewProps .IMPORTANT_FOR_ACCESSIBILITY ->
83
83
mViewManager.setImportantForAccessibility(view, value as String? )
84
84
85
+ ViewProps .SCREEN_READER_FOCUSABLE ->
86
+ mViewManager.setScreenReaderFocusable(view, value as Boolean? ? : false )
87
+
85
88
ViewProps .ROLE -> mViewManager.setRole(view, value as String? )
86
89
ViewProps .NATIVE_ID -> mViewManager.setNativeId(view, value as String? )
87
90
ViewProps .ACCESSIBILITY_LABELLED_BY -> {
Original file line number Diff line number Diff line change @@ -159,6 +159,7 @@ public object ViewProps {
159
159
public const val ACCESSIBILITY_LABELLED_BY : String = " accessibilityLabelledBy"
160
160
public const val ACCESSIBILITY_ORDER : String = " experimental_accessibilityOrder"
161
161
public const val IMPORTANT_FOR_ACCESSIBILITY : String = " importantForAccessibility"
162
+ public const val SCREEN_READER_FOCUSABLE : String = " screenReaderFocusable"
162
163
public const val ROLE : String = " role"
163
164
// DEPRECATED
164
165
public const val ROTATION : String = " rotation"
Original file line number Diff line number Diff line change @@ -85,6 +85,15 @@ HostPlatformViewProps::HostPlatformViewProps(
85
85
rawProps,
86
86
" renderToHardwareTextureAndroid" ,
87
87
sourceProps.renderToHardwareTextureAndroid,
88
+ {})),
89
+ screenReaderFocusable(
90
+ ReactNativeFeatureFlags::enableCppPropsIteratorSetter ()
91
+ ? sourceProps.screenReaderFocusable
92
+ : convertRawProp(
93
+ context,
94
+ rawProps,
95
+ " screenReaderFocusable" ,
96
+ sourceProps.screenReaderFocusable,
88
97
{})) {}
89
98
90
99
#define VIEW_EVENT_CASE (eventType ) \
@@ -119,6 +128,7 @@ void HostPlatformViewProps::setProp(
119
128
RAW_SET_PROP_SWITCH_CASE_BASIC (hasTVPreferredFocus);
120
129
RAW_SET_PROP_SWITCH_CASE_BASIC (needsOffscreenAlphaCompositing);
121
130
RAW_SET_PROP_SWITCH_CASE_BASIC (renderToHardwareTextureAndroid);
131
+ RAW_SET_PROP_SWITCH_CASE_BASIC (screenReaderFocusable);
122
132
}
123
133
}
124
134
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ class HostPlatformViewProps : public BaseViewProps {
47
47
bool hasTVPreferredFocus{false };
48
48
bool needsOffscreenAlphaCompositing{false };
49
49
bool renderToHardwareTextureAndroid{false };
50
+ bool screenReaderFocusable{false };
50
51
51
52
#pragma mark - Convenience Methods
52
53
Original file line number Diff line number Diff line change @@ -21,7 +21,8 @@ inline bool formsView(const ViewProps& viewProps) {
21
21
viewProps.nativeForeground .has_value () || viewProps.focusable ||
22
22
viewProps.hasTVPreferredFocus ||
23
23
viewProps.needsOffscreenAlphaCompositing ||
24
- viewProps.renderToHardwareTextureAndroid ;
24
+ viewProps.renderToHardwareTextureAndroid ||
25
+ viewProps.screenReaderFocusable ;
25
26
}
26
27
27
28
} // namespace facebook::react::HostPlatformViewTraitsInitializer
You can’t perform that action at this time.
0 commit comments