diff --git a/packages/react-native/Libraries/Text/Text.js b/packages/react-native/Libraries/Text/Text.js
index df51994f241..fb5c10b72b7 100644
--- a/packages/react-native/Libraries/Text/Text.js
+++ b/packages/react-native/Libraries/Text/Text.js
@@ -152,10 +152,7 @@ if (ReactNativeFeatureFlags.reduceDefaultPropsInText()) {
_disabled !== true;
const shouldUseLinkRole =
- ReactNativeFeatureFlags.shouldUseLinkRoleForPressableText() &&
- isPressable &&
- accessibilityRole == null &&
- role == null;
+ isPressable && accessibilityRole == null && role == null;
const _accessibilityRole =
accessibilityRole ?? (shouldUseLinkRole ? 'link' : undefined);
@@ -420,10 +417,7 @@ if (ReactNativeFeatureFlags.reduceDefaultPropsInText()) {
_disabled !== true;
const shouldUseLinkRole =
- ReactNativeFeatureFlags.shouldUseLinkRoleForPressableText() &&
- isPressable &&
- accessibilityRole == null &&
- role == null;
+ isPressable && accessibilityRole == null && role == null;
const _accessibilityRole =
accessibilityRole ?? (shouldUseLinkRole ? 'link' : undefined);
diff --git a/packages/react-native/Libraries/Text/__tests__/Text-test.js b/packages/react-native/Libraries/Text/__tests__/Text-test.js
index ee81bb1a806..522219e693f 100644
--- a/packages/react-native/Libraries/Text/__tests__/Text-test.js
+++ b/packages/react-native/Libraries/Text/__tests__/Text-test.js
@@ -12,7 +12,6 @@ import type {ReactTestRendererJSON} from '../../Utilities/ReactNativeTestTools';
import type {ReactTestRenderer} from 'react-test-renderer';
import {create} from '../../../jest/renderer';
-import * as ReactNativeFeatureFlags from '../../../src/private/featureflags/ReactNativeFeatureFlags';
import flattenStyle from '../../StyleSheet/flattenStyle';
import * as React from 'react';
@@ -76,252 +75,153 @@ describe('Text', () => {
});
describe('accessibilityRole with onPress/onLongPress', () => {
- describe('when shouldUseLinkRoleForPressableText flag is OFF (default)', () => {
- beforeEach(() => {
- jest
- .spyOn(ReactNativeFeatureFlags, 'shouldUseLinkRoleForPressableText')
- .mockReturnValue(false);
- });
+ it('automatically sets accessibilityRole="link" when onPress is provided', async () => {
+ const instance = await create(
+ {}}>Clickable Text,
+ );
- afterEach(() => {
- jest.restoreAllMocks();
- });
-
- it('does not automatically set accessibilityRole when onPress is provided', async () => {
- const instance = await create(
- {}}>Clickable Text,
- );
-
- expect(omitRefAndFlattenStyle(instance)).toMatchInlineSnapshot(`
-
- Clickable Text
-
- `);
- });
-
- it('does not automatically set accessibilityRole when onLongPress is provided', async () => {
- const instance = await create(
- {}}>Long Press Text,
- );
-
- expect(omitRefAndFlattenStyle(instance)).toMatchInlineSnapshot(`
-
- Long Press Text
-
- `);
- });
-
- it('does not automatically set accessibilityRole when onStartShouldSetResponder is provided', async () => {
- const instance = await create(
- true}>Responder Text,
- );
-
- expect(omitRefAndFlattenStyle(instance)).toMatchInlineSnapshot(`
-
- Responder Text
-
- `);
- });
-
- it('respects explicit accessibilityRole', async () => {
- const instance = await create(
- {}}>
- Explicit Button Role
- ,
- );
-
- expect(omitRefAndFlattenStyle(instance)).toMatchInlineSnapshot(`
-
- Explicit Button Role
-
- `);
- });
+ expect(omitRefAndFlattenStyle(instance)).toMatchInlineSnapshot(`
+
+ Clickable Text
+
+ `);
});
- describe('when shouldUseLinkRoleForPressableText flag is ON', () => {
- beforeEach(() => {
- jest
- .spyOn(ReactNativeFeatureFlags, 'shouldUseLinkRoleForPressableText')
- .mockReturnValue(true);
- });
+ it('automatically sets accessibilityRole="link" when onLongPress is provided', async () => {
+ const instance = await create(
+ {}}>Long Press Text,
+ );
- afterEach(() => {
- jest.restoreAllMocks();
- });
+ expect(omitRefAndFlattenStyle(instance)).toMatchInlineSnapshot(`
+
+ Long Press Text
+
+ `);
+ });
- it('automatically sets accessibilityRole="link" when onPress is provided', async () => {
- const instance = await create(
- {}}>Clickable Text,
- );
+ it('automatically sets accessibilityRole="link" when onStartShouldSetResponder is provided', async () => {
+ const instance = await create(
+ true}>Responder Text,
+ );
- expect(omitRefAndFlattenStyle(instance)).toMatchInlineSnapshot(`
-
- Clickable Text
-
- `);
- });
+ expect(omitRefAndFlattenStyle(instance)).toMatchInlineSnapshot(`
+
+ Responder Text
+
+ `);
+ });
- it('automatically sets accessibilityRole="link" when onLongPress is provided', async () => {
- const instance = await create(
- {}}>Long Press Text,
- );
+ it('respects explicit accessibilityRole', async () => {
+ const instance = await create(
+ {}}>
+ Explicit Button Role
+ ,
+ );
- expect(omitRefAndFlattenStyle(instance)).toMatchInlineSnapshot(`
-
- Long Press Text
-
- `);
- });
+ expect(omitRefAndFlattenStyle(instance)).toMatchInlineSnapshot(`
+
+ Explicit Button Role
+
+ `);
+ });
- it('automatically sets accessibilityRole="link" when onStartShouldSetResponder is provided', async () => {
- const instance = await create(
- true}>Responder Text,
- );
+ it('respects explicit role prop', async () => {
+ // $FlowFixMe[prop-missing]
+ const instance = await create(
+ {}} role="button">
+ Explicit Role Prop
+ ,
+ );
- expect(omitRefAndFlattenStyle(instance)).toMatchInlineSnapshot(`
-
- Responder Text
-
- `);
- });
+ expect(omitRefAndFlattenStyle(instance)).toMatchInlineSnapshot(`
+
+ Explicit Role Prop
+
+ `);
+ });
- it('respects explicit accessibilityRole', async () => {
- const instance = await create(
- {}}>
- Explicit Button Role
- ,
- );
+ it('does not automatically set accessibilityRole when disabled', async () => {
+ const instance = await create(
+ {}}>
+ Disabled Pressable Text
+ ,
+ );
- expect(omitRefAndFlattenStyle(instance)).toMatchInlineSnapshot(`
-
- Explicit Button Role
-
- `);
- });
-
- it('respects explicit role prop', async () => {
- // $FlowFixMe[prop-missing]
- const instance = await create(
- {}} role="button">
- Explicit Role Prop
- ,
- );
-
- expect(omitRefAndFlattenStyle(instance)).toMatchInlineSnapshot(`
-
- Explicit Role Prop
-
- `);
- });
-
- it('does not automatically set accessibilityRole when disabled', async () => {
- const instance = await create(
- {}}>
- Disabled Pressable Text
- ,
- );
-
- expect(omitRefAndFlattenStyle(instance)).toMatchInlineSnapshot(`
-
- Disabled Pressable Text
-
- `);
- });
+ }
+ accessible={true}
+ allowFontScaling={true}
+ disabled={true}
+ ellipsizeMode="tail"
+ >
+ Disabled Pressable Text
+
+ `);
+ });
- it('automatically sets accessibilityRole="link" for nested Text with onPress', async () => {
- const instance = await create(
-
- Parent Text {}}>Nested Clickable Link
- ,
- );
+ it('automatically sets accessibilityRole="link" for nested Text with onPress', async () => {
+ const instance = await create(
+
+ Parent Text {}}>Nested Clickable Link
+ ,
+ );
- expect(omitRefAndFlattenStyle(instance)).toMatchInlineSnapshot(`
+ expect(omitRefAndFlattenStyle(instance)).toMatchInlineSnapshot(`
+
+ Parent Text
- Parent Text
-
- Nested Clickable Link
-
+ Nested Clickable Link
- `);
- });
+
+ `);
});
it('does not set accessibilityRole when no press handlers are provided', async () => {
diff --git a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js
index eadb8d2a0ad..501e5c2197b 100644
--- a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js
+++ b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js
@@ -980,16 +980,6 @@ const definitions: FeatureFlagDefinitions = {
},
ossReleaseStage: 'none',
},
- shouldUseLinkRoleForPressableText: {
- defaultValue: true,
- metadata: {
- description:
- 'Set accessibilityRole to "link" for pressable Text components by default.',
- expectedReleaseValue: true,
- purpose: 'release',
- },
- ossReleaseStage: 'none',
- },
shouldUseRemoveClippedSubviewsAsDefaultOnIOS: {
defaultValue: false,
metadata: {
diff --git a/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js
index 5ef19ea424b..be04495dc73 100644
--- a/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js
+++ b/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
- * @generated SignedSource<>
+ * @generated SignedSource<<0acb1755465fae151917d6043a737331>>
* @flow strict
* @noformat
*/
@@ -38,7 +38,6 @@ export type ReactNativeFeatureFlagsJsOnly = $ReadOnly<{
reduceDefaultPropsInImage: Getter,
reduceDefaultPropsInText: Getter,
shouldUseAnimatedObjectForTransform: Getter,
- shouldUseLinkRoleForPressableText: Getter,
shouldUseRemoveClippedSubviewsAsDefaultOnIOS: Getter,
shouldUseSetNativePropsInFabric: Getter,
}>;
@@ -178,11 +177,6 @@ export const reduceDefaultPropsInText: Getter = createJavaScriptFlagGet
*/
export const shouldUseAnimatedObjectForTransform: Getter = createJavaScriptFlagGetter('shouldUseAnimatedObjectForTransform', false);
-/**
- * Set accessibilityRole to "link" for pressable Text components by default.
- */
-export const shouldUseLinkRoleForPressableText: Getter = createJavaScriptFlagGetter('shouldUseLinkRoleForPressableText', true);
-
/**
* removeClippedSubviews prop will be used as the default in FlatList on iOS to match Android
*/