Skip to content

Commit 713facd

Browse files
twasilczykfacebook-github-bot
authored andcommitted
Inherit text's role and accessibilityRole together (#58022)
Summary: Inheriting `role` and `accessibilityRole` independently leads to some links inheriting `role=heading` while setting their own `accessibilityRole=link`. This caused the former to overrule the latter, missing link detection. Changelog: [Internal] Differential Revision: D116668886
1 parent 892ea5e commit 713facd

22 files changed

Lines changed: 266 additions & 103 deletions

‎packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<eb0bafceba60cb439a4be3d68b890725>>
7+
* @generated SignedSource<<c47196d81d6d7afd60456bf62a5a958c>>
88
*/
99

1010
/**
@@ -114,6 +114,12 @@ public object ReactNativeFeatureFlags {
114114
@JvmStatic
115115
public fun enableAccumulatedUpdatesInRawPropsAndroid(): Boolean = accessor.enableAccumulatedUpdatesInRawPropsAndroid()
116116

117+
/**
118+
* When enabled, a text fragment that sets either `role` or `accessibilityRole` (the two are aliases) inherits neither.
119+
*/
120+
@JvmStatic
121+
public fun enableAliasedTextRoleInheritance(): Boolean = accessor.enableAliasedTextRoleInheritance()
122+
117123
/**
118124
* When enabled, a View with reduced opacity that contains an elevated descendant is composited offscreen so the elevation shadow fades uniformly instead of rendering as banded per-primitive alpha.
119125
*/

‎packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<0107593110db613063b6f4ceb50d8e58>>
7+
* @generated SignedSource<<9d33cd35fc1fad82ec29eebf410cb999>>
88
*/
99

1010
/**
@@ -34,6 +34,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
3434
private var disableViewPreallocationAndroidCache: Boolean? = null
3535
private var enableAccessibilityOrderCache: Boolean? = null
3636
private var enableAccumulatedUpdatesInRawPropsAndroidCache: Boolean? = null
37+
private var enableAliasedTextRoleInheritanceCache: Boolean? = null
3738
private var enableAndroidAutoOffscreenCompositingForElevationCache: Boolean? = null
3839
private var enableAndroidTextMeasurementOptimizationsCache: Boolean? = null
3940
private var enableAsyncDiskCacheCheckInMultiSourceImageAndroidCache: Boolean? = null
@@ -240,6 +241,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
240241
return cached
241242
}
242243

244+
override fun enableAliasedTextRoleInheritance(): Boolean {
245+
var cached = enableAliasedTextRoleInheritanceCache
246+
if (cached == null) {
247+
cached = ReactNativeFeatureFlagsCxxInterop.enableAliasedTextRoleInheritance()
248+
enableAliasedTextRoleInheritanceCache = cached
249+
}
250+
return cached
251+
}
252+
243253
override fun enableAndroidAutoOffscreenCompositingForElevation(): Boolean {
244254
var cached = enableAndroidAutoOffscreenCompositingForElevationCache
245255
if (cached == null) {

‎packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<fa0374808e3cbe7122ca993780c0b627>>
7+
* @generated SignedSource<<4b1c6e36a90327d1fdc4c47972a3bf1b>>
88
*/
99

1010
/**
@@ -56,6 +56,8 @@ public object ReactNativeFeatureFlagsCxxInterop {
5656

5757
@DoNotStrip @JvmStatic public external fun enableAccumulatedUpdatesInRawPropsAndroid(): Boolean
5858

59+
@DoNotStrip @JvmStatic public external fun enableAliasedTextRoleInheritance(): Boolean
60+
5961
@DoNotStrip @JvmStatic public external fun enableAndroidAutoOffscreenCompositingForElevation(): Boolean
6062

6163
@DoNotStrip @JvmStatic public external fun enableAndroidTextMeasurementOptimizations(): Boolean

‎packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<768077a22c110aa98ab02bc96eec695b>>
7+
* @generated SignedSource<<037d51466544717f0648b667bbeb48cd>>
88
*/
99

1010
/**
@@ -51,6 +51,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
5151

5252
override fun enableAccumulatedUpdatesInRawPropsAndroid(): Boolean = false
5353

54+
override fun enableAliasedTextRoleInheritance(): Boolean = true
55+
5456
override fun enableAndroidAutoOffscreenCompositingForElevation(): Boolean = false
5557

5658
override fun enableAndroidTextMeasurementOptimizations(): Boolean = false

‎packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<86ebc7307e7ebe2023e909a868ed3117>>
7+
* @generated SignedSource<<c94e715560ce20c62811f420be80b716>>
88
*/
99

1010
/**
@@ -38,6 +38,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
3838
private var disableViewPreallocationAndroidCache: Boolean? = null
3939
private var enableAccessibilityOrderCache: Boolean? = null
4040
private var enableAccumulatedUpdatesInRawPropsAndroidCache: Boolean? = null
41+
private var enableAliasedTextRoleInheritanceCache: Boolean? = null
4142
private var enableAndroidAutoOffscreenCompositingForElevationCache: Boolean? = null
4243
private var enableAndroidTextMeasurementOptimizationsCache: Boolean? = null
4344
private var enableAsyncDiskCacheCheckInMultiSourceImageAndroidCache: Boolean? = null
@@ -258,6 +259,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
258259
return cached
259260
}
260261

262+
override fun enableAliasedTextRoleInheritance(): Boolean {
263+
var cached = enableAliasedTextRoleInheritanceCache
264+
if (cached == null) {
265+
cached = currentProvider.enableAliasedTextRoleInheritance()
266+
accessedFeatureFlags.add("enableAliasedTextRoleInheritance")
267+
enableAliasedTextRoleInheritanceCache = cached
268+
}
269+
return cached
270+
}
271+
261272
override fun enableAndroidAutoOffscreenCompositingForElevation(): Boolean {
262273
var cached = enableAndroidAutoOffscreenCompositingForElevationCache
263274
if (cached == null) {

‎packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<c83fba10dc6f7d596e3bcd9725c64e6e>>
7+
* @generated SignedSource<<1e3f621bf5b2079f2923cc0fcce41fb7>>
88
*/
99

1010
/**
@@ -51,6 +51,8 @@ public interface ReactNativeFeatureFlagsProvider {
5151

5252
@DoNotStrip public fun enableAccumulatedUpdatesInRawPropsAndroid(): Boolean
5353

54+
@DoNotStrip public fun enableAliasedTextRoleInheritance(): Boolean
55+
5456
@DoNotStrip public fun enableAndroidAutoOffscreenCompositingForElevation(): Boolean
5557

5658
@DoNotStrip public fun enableAndroidTextMeasurementOptimizations(): Boolean

‎packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<200266835197634d13de07182d80a2c1>>
7+
* @generated SignedSource<<eca2a21d7c3095d57896e1f690cd95ec>>
88
*/
99

1010
/**
@@ -123,6 +123,12 @@ class ReactNativeFeatureFlagsJavaProvider
123123
return method(javaProvider_);
124124
}
125125

126+
bool enableAliasedTextRoleInheritance() override {
127+
static const auto method =
128+
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableAliasedTextRoleInheritance");
129+
return method(javaProvider_);
130+
}
131+
126132
bool enableAndroidAutoOffscreenCompositingForElevation() override {
127133
static const auto method =
128134
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableAndroidAutoOffscreenCompositingForElevation");
@@ -671,6 +677,11 @@ bool JReactNativeFeatureFlagsCxxInterop::enableAccumulatedUpdatesInRawPropsAndro
671677
return ReactNativeFeatureFlags::enableAccumulatedUpdatesInRawPropsAndroid();
672678
}
673679

680+
bool JReactNativeFeatureFlagsCxxInterop::enableAliasedTextRoleInheritance(
681+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
682+
return ReactNativeFeatureFlags::enableAliasedTextRoleInheritance();
683+
}
684+
674685
bool JReactNativeFeatureFlagsCxxInterop::enableAndroidAutoOffscreenCompositingForElevation(
675686
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
676687
return ReactNativeFeatureFlags::enableAndroidAutoOffscreenCompositingForElevation();
@@ -1139,6 +1150,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
11391150
makeNativeMethod(
11401151
"enableAccumulatedUpdatesInRawPropsAndroid",
11411152
JReactNativeFeatureFlagsCxxInterop::enableAccumulatedUpdatesInRawPropsAndroid),
1153+
makeNativeMethod(
1154+
"enableAliasedTextRoleInheritance",
1155+
JReactNativeFeatureFlagsCxxInterop::enableAliasedTextRoleInheritance),
11421156
makeNativeMethod(
11431157
"enableAndroidAutoOffscreenCompositingForElevation",
11441158
JReactNativeFeatureFlagsCxxInterop::enableAndroidAutoOffscreenCompositingForElevation),

‎packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<13aa248dae556b06b31c25a28e448460>>
7+
* @generated SignedSource<<782efe2f12e008b34b15cf0e09776b78>>
88
*/
99

1010
/**
@@ -72,6 +72,9 @@ class JReactNativeFeatureFlagsCxxInterop
7272
static bool enableAccumulatedUpdatesInRawPropsAndroid(
7373
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
7474

75+
static bool enableAliasedTextRoleInheritance(
76+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
77+
7578
static bool enableAndroidAutoOffscreenCompositingForElevation(
7679
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
7780

‎packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<fc4b67b43c846eac0085ed4a5528a170>>
7+
* @generated SignedSource<<b01dac5241d3723788663265d459450b>>
88
*/
99

1010
/**
@@ -82,6 +82,10 @@ bool ReactNativeFeatureFlags::enableAccumulatedUpdatesInRawPropsAndroid() {
8282
return getAccessor().enableAccumulatedUpdatesInRawPropsAndroid();
8383
}
8484

85+
bool ReactNativeFeatureFlags::enableAliasedTextRoleInheritance() {
86+
return getAccessor().enableAliasedTextRoleInheritance();
87+
}
88+
8589
bool ReactNativeFeatureFlags::enableAndroidAutoOffscreenCompositingForElevation() {
8690
return getAccessor().enableAndroidAutoOffscreenCompositingForElevation();
8791
}

‎packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<1a9a8a587b477b6aa0d3aa57e30272c2>>
7+
* @generated SignedSource<<f54f9b6917ef84daa5beb19ff5aadbd8>>
88
*/
99

1010
/**
@@ -111,6 +111,11 @@ class ReactNativeFeatureFlags {
111111
*/
112112
RN_EXPORT static bool enableAccumulatedUpdatesInRawPropsAndroid();
113113

114+
/**
115+
* When enabled, a text fragment that sets either `role` or `accessibilityRole` (the two are aliases) inherits neither.
116+
*/
117+
RN_EXPORT static bool enableAliasedTextRoleInheritance();
118+
114119
/**
115120
* When enabled, a View with reduced opacity that contains an elevated descendant is composited offscreen so the elevation shadow fades uniformly instead of rendering as banded per-primitive alpha.
116121
*/

0 commit comments

Comments
 (0)