File tree 10 files changed +46
-5
lines changed
src/main/java/com/facebook/react/uimanager
ReactCommon/react/renderer/components/view
10 files changed +46
-5
lines changed Original file line number Diff line number Diff line change @@ -101,8 +101,8 @@ export interface AccessibilityProps
101
101
}
102
102
103
103
export type AccessibilityActionInfo = Readonly < {
104
- name : AccessibilityActionName | string ;
105
- label ?: string | undefined ;
104
+ name : AccessibilityActionName | string ,
105
+ label ?: string | undefined ,
106
106
} > ;
107
107
108
108
export type AccessibilityActionName =
@@ -136,8 +136,8 @@ export type AccessibilityActionName =
136
136
137
137
export type AccessibilityActionEvent = NativeSyntheticEvent <
138
138
Readonly < {
139
- actionName : string ;
140
- } >
139
+ actionName : string ,
140
+ } > ,
141
141
> ;
142
142
143
143
export interface AccessibilityState {
@@ -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 , @ Nullable 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 @@ -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 @@ -199,6 +199,15 @@ AccessibilityProps::AccessibilityProps(
199
199
" importantForAccessibility" ,
200
200
sourceProps.importantForAccessibility,
201
201
ImportantForAccessibility::Auto)),
202
+ screenReaderFocusable(
203
+ ReactNativeFeatureFlags::enableCppPropsIteratorSetter ()
204
+ ? sourceProps.screenReaderFocusable
205
+ : convertRawProp(
206
+ context,
207
+ rawProps,
208
+ " screenReaderFocusable" ,
209
+ sourceProps.screenReaderFocusable,
210
+ false )),
202
211
testId(
203
212
ReactNativeFeatureFlags::enableCppPropsIteratorSetter ()
204
213
? sourceProps.testId
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ class AccessibilityProps {
55
55
bool onAccessibilityAction{};
56
56
ImportantForAccessibility importantForAccessibility{
57
57
ImportantForAccessibility::Auto};
58
+ bool screenReaderFocusable{false };
58
59
Role role{Role::None};
59
60
std::string testId;
60
61
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ void ViewShadowNode::initialize() noexcept {
63
63
viewProps.mixBlendMode != BlendMode::Normal ||
64
64
viewProps.isolation == Isolation::Isolate ||
65
65
HostPlatformViewTraitsInitializer::formsStackingContext (viewProps) ||
66
- !viewProps.accessibilityOrder .empty ();
66
+ !viewProps.accessibilityOrder .empty () || viewProps. screenReaderFocusable ;
67
67
68
68
bool formsView = formsStackingContext ||
69
69
isColorMeaningful (viewProps.backgroundColor ) || hasBorder () ||
You can’t perform that action at this time.
0 commit comments