Skip to content

Commit 5142409

Browse files
twasilczykmeta-codesync[bot]
authored andcommitted
Inherit text's role and accessibilityRole together (#58022)
Summary: Pull Request resolved: #58022 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 6c4cf29 commit 5142409

22 files changed

Lines changed: 262 additions & 99 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<<d5bab65a116d6f6d3415c5c8a2f08db9>>
7+
* @generated SignedSource<<4c99c06bfbb07f74ff5063cc6385212f>>
88
*/
99

1010
/**
@@ -102,6 +102,12 @@ public object ReactNativeFeatureFlags {
102102
@JvmStatic
103103
public fun enableAccumulatedUpdatesInRawPropsAndroid(): Boolean = accessor.enableAccumulatedUpdatesInRawPropsAndroid()
104104

105+
/**
106+
* When enabled, a text fragment that sets either `role` or `accessibilityRole` (the two are aliases) always replaces both inherited values.
107+
*/
108+
@JvmStatic
109+
public fun enableAliasedTextRoleInheritance(): Boolean = accessor.enableAliasedTextRoleInheritance()
110+
105111
/**
106112
* Enables various optimizations throughout the path of measuring text on Android.
107113
*/

‎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<<331c699ee09143bbb98a81857cb2659c>>
7+
* @generated SignedSource<<d636e8ff889ae10def17fe5828dffacd>>
88
*/
99

1010
/**
@@ -32,6 +32,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
3232
private var disableViewPreallocationAndroidCache: Boolean? = null
3333
private var enableAccessibilityOrderCache: Boolean? = null
3434
private var enableAccumulatedUpdatesInRawPropsAndroidCache: Boolean? = null
35+
private var enableAliasedTextRoleInheritanceCache: Boolean? = null
3536
private var enableAndroidTextMeasurementOptimizationsCache: Boolean? = null
3637
private var enableBridgelessArchitectureCache: Boolean? = null
3738
private var enableCppPropsIteratorSetterCache: Boolean? = null
@@ -216,6 +217,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
216217
return cached
217218
}
218219

220+
override fun enableAliasedTextRoleInheritance(): Boolean {
221+
var cached = enableAliasedTextRoleInheritanceCache
222+
if (cached == null) {
223+
cached = ReactNativeFeatureFlagsCxxInterop.enableAliasedTextRoleInheritance()
224+
enableAliasedTextRoleInheritanceCache = cached
225+
}
226+
return cached
227+
}
228+
219229
override fun enableAndroidTextMeasurementOptimizations(): Boolean {
220230
var cached = enableAndroidTextMeasurementOptimizationsCache
221231
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<<a9cf60776cac41ff2ebb6a5e267343ca>>
7+
* @generated SignedSource<<2265e489d3022f17aad22046fc44d632>>
88
*/
99

1010
/**
@@ -52,6 +52,8 @@ public object ReactNativeFeatureFlagsCxxInterop {
5252

5353
@DoNotStrip @JvmStatic public external fun enableAccumulatedUpdatesInRawPropsAndroid(): Boolean
5454

55+
@DoNotStrip @JvmStatic public external fun enableAliasedTextRoleInheritance(): Boolean
56+
5557
@DoNotStrip @JvmStatic public external fun enableAndroidTextMeasurementOptimizations(): Boolean
5658

5759
@DoNotStrip @JvmStatic public external fun enableBridgelessArchitecture(): 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<<74896623764d3d01d2925fdcf30948f1>>
7+
* @generated SignedSource<<37fd2f506d305ef1b4cb79cdf01a957f>>
88
*/
99

1010
/**
@@ -47,6 +47,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
4747

4848
override fun enableAccumulatedUpdatesInRawPropsAndroid(): Boolean = false
4949

50+
override fun enableAliasedTextRoleInheritance(): Boolean = true
51+
5052
override fun enableAndroidTextMeasurementOptimizations(): Boolean = false
5153

5254
override fun enableBridgelessArchitecture(): Boolean = true

‎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<<1e05552bb01ea7e80fde1c19b5199caa>>
7+
* @generated SignedSource<<e5b1b5cbb59e0497f41296547737e3d0>>
88
*/
99

1010
/**
@@ -36,6 +36,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
3636
private var disableViewPreallocationAndroidCache: Boolean? = null
3737
private var enableAccessibilityOrderCache: Boolean? = null
3838
private var enableAccumulatedUpdatesInRawPropsAndroidCache: Boolean? = null
39+
private var enableAliasedTextRoleInheritanceCache: Boolean? = null
3940
private var enableAndroidTextMeasurementOptimizationsCache: Boolean? = null
4041
private var enableBridgelessArchitectureCache: Boolean? = null
4142
private var enableCppPropsIteratorSetterCache: Boolean? = null
@@ -232,6 +233,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
232233
return cached
233234
}
234235

236+
override fun enableAliasedTextRoleInheritance(): Boolean {
237+
var cached = enableAliasedTextRoleInheritanceCache
238+
if (cached == null) {
239+
cached = currentProvider.enableAliasedTextRoleInheritance()
240+
accessedFeatureFlags.add("enableAliasedTextRoleInheritance")
241+
enableAliasedTextRoleInheritanceCache = cached
242+
}
243+
return cached
244+
}
245+
235246
override fun enableAndroidTextMeasurementOptimizations(): Boolean {
236247
var cached = enableAndroidTextMeasurementOptimizationsCache
237248
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<<998a99e804cf713c8ce8adafa1b1b83b>>
7+
* @generated SignedSource<<81de1016602b33921cf9e219bd218bab>>
88
*/
99

1010
/**
@@ -47,6 +47,8 @@ public interface ReactNativeFeatureFlagsProvider {
4747

4848
@DoNotStrip public fun enableAccumulatedUpdatesInRawPropsAndroid(): Boolean
4949

50+
@DoNotStrip public fun enableAliasedTextRoleInheritance(): Boolean
51+
5052
@DoNotStrip public fun enableAndroidTextMeasurementOptimizations(): Boolean
5153

5254
@DoNotStrip public fun enableBridgelessArchitecture(): 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<<7513432f85b9832654814f381b13fe97>>
7+
* @generated SignedSource<<624a8ab1b4f1477db5df868e1aabc704>>
88
*/
99

1010
/**
@@ -111,6 +111,12 @@ class ReactNativeFeatureFlagsJavaProvider
111111
return method(javaProvider_);
112112
}
113113

114+
bool enableAliasedTextRoleInheritance() override {
115+
static const auto method =
116+
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableAliasedTextRoleInheritance");
117+
return method(javaProvider_);
118+
}
119+
114120
bool enableAndroidTextMeasurementOptimizations() override {
115121
static const auto method =
116122
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableAndroidTextMeasurementOptimizations");
@@ -625,6 +631,11 @@ bool JReactNativeFeatureFlagsCxxInterop::enableAccumulatedUpdatesInRawPropsAndro
625631
return ReactNativeFeatureFlags::enableAccumulatedUpdatesInRawPropsAndroid();
626632
}
627633

634+
bool JReactNativeFeatureFlagsCxxInterop::enableAliasedTextRoleInheritance(
635+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
636+
return ReactNativeFeatureFlags::enableAliasedTextRoleInheritance();
637+
}
638+
628639
bool JReactNativeFeatureFlagsCxxInterop::enableAndroidTextMeasurementOptimizations(
629640
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
630641
return ReactNativeFeatureFlags::enableAndroidTextMeasurementOptimizations();
@@ -1067,6 +1078,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
10671078
makeNativeMethod(
10681079
"enableAccumulatedUpdatesInRawPropsAndroid",
10691080
JReactNativeFeatureFlagsCxxInterop::enableAccumulatedUpdatesInRawPropsAndroid),
1081+
makeNativeMethod(
1082+
"enableAliasedTextRoleInheritance",
1083+
JReactNativeFeatureFlagsCxxInterop::enableAliasedTextRoleInheritance),
10701084
makeNativeMethod(
10711085
"enableAndroidTextMeasurementOptimizations",
10721086
JReactNativeFeatureFlagsCxxInterop::enableAndroidTextMeasurementOptimizations),

‎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<<9689c541fa98ffbaf9f5d83077ab1208>>
7+
* @generated SignedSource<<dc8e79caeee1edeaca3508b96b3bc590>>
88
*/
99

1010
/**
@@ -66,6 +66,9 @@ class JReactNativeFeatureFlagsCxxInterop
6666
static bool enableAccumulatedUpdatesInRawPropsAndroid(
6767
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
6868

69+
static bool enableAliasedTextRoleInheritance(
70+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
71+
6972
static bool enableAndroidTextMeasurementOptimizations(
7073
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
7174

‎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<<acec83211036df307dd8711e96fcb80c>>
7+
* @generated SignedSource<<d05965cfcfa0b9543aed461833b9a1cc>>
88
*/
99

1010
/**
@@ -74,6 +74,10 @@ bool ReactNativeFeatureFlags::enableAccumulatedUpdatesInRawPropsAndroid() {
7474
return getAccessor().enableAccumulatedUpdatesInRawPropsAndroid();
7575
}
7676

77+
bool ReactNativeFeatureFlags::enableAliasedTextRoleInheritance() {
78+
return getAccessor().enableAliasedTextRoleInheritance();
79+
}
80+
7781
bool ReactNativeFeatureFlags::enableAndroidTextMeasurementOptimizations() {
7882
return getAccessor().enableAndroidTextMeasurementOptimizations();
7983
}

‎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<<e437a03ac130e2f24a857a64b3677490>>
7+
* @generated SignedSource<<41032de66002cb246765c16882df529f>>
88
*/
99

1010
/**
@@ -99,6 +99,11 @@ class ReactNativeFeatureFlags {
9999
*/
100100
RN_EXPORT static bool enableAccumulatedUpdatesInRawPropsAndroid();
101101

102+
/**
103+
* When enabled, a text fragment that sets either `role` or `accessibilityRole` (the two are aliases) always replaces both inherited values.
104+
*/
105+
RN_EXPORT static bool enableAliasedTextRoleInheritance();
106+
102107
/**
103108
* Enables various optimizations throughout the path of measuring text on Android.
104109
*/

0 commit comments

Comments
 (0)