diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt index 4177599a0193..ef83ffec636a 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt @@ -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<<6ee52545e85d6c96c00087c3dd3d2b91>> */ /** @@ -270,6 +270,12 @@ public object ReactNativeFeatureFlags { @JvmStatic public fun enableInteractableResponderViews(): Boolean = accessor.enableInteractableResponderViews() + /** + * When enabled, inline text with a button role produces a ClickableSpan (like a link). + */ + @JvmStatic + public fun enableInteractiveInlineButtons(): Boolean = accessor.enableInteractiveInlineButtons() + /** * This is to fix the issue with interop view manager where component descriptor lookup is causing ViewManager to preload. */ diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt index 02d37fc5c6d5..e720559b5885 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt @@ -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<<666ccc72b92cb71cee62acb9d338903f>> + * @generated SignedSource<<650b684ffd6117e349156de6598035e3>> */ /** @@ -60,6 +60,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces private var enableImperativeEventsCache: Boolean? = null private var enableImperativeFocusCache: Boolean? = null private var enableInteractableResponderViewsCache: Boolean? = null + private var enableInteractiveInlineButtonsCache: Boolean? = null private var enableInteropViewManagerClassLookUpOptimizationIOSCache: Boolean? = null private var enableIntersectionObserverByDefaultCache: Boolean? = null private var enableKeyEventsCache: Boolean? = null @@ -484,6 +485,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces return cached } + override fun enableInteractiveInlineButtons(): Boolean { + var cached = enableInteractiveInlineButtonsCache + if (cached == null) { + cached = ReactNativeFeatureFlagsCxxInterop.enableInteractiveInlineButtons() + enableInteractiveInlineButtonsCache = cached + } + return cached + } + override fun enableInteropViewManagerClassLookUpOptimizationIOS(): Boolean { var cached = enableInteropViewManagerClassLookUpOptimizationIOSCache if (cached == null) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt index 64732d187c85..753ed471d079 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt @@ -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<<62e104bae80f5d1b4bc66fbe5b1682aa>> + * @generated SignedSource<<511d3d1110dd38f9dae019b4cc26000b>> */ /** @@ -108,6 +108,8 @@ public object ReactNativeFeatureFlagsCxxInterop { @DoNotStrip @JvmStatic public external fun enableInteractableResponderViews(): Boolean + @DoNotStrip @JvmStatic public external fun enableInteractiveInlineButtons(): Boolean + @DoNotStrip @JvmStatic public external fun enableInteropViewManagerClassLookUpOptimizationIOS(): Boolean @DoNotStrip @JvmStatic public external fun enableIntersectionObserverByDefault(): Boolean diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt index a04b0a9efbc7..b3ccf1b92a78 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt @@ -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<<48d155fc648fd425ad85f950771c122c>> */ /** @@ -103,6 +103,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi override fun enableInteractableResponderViews(): Boolean = false + override fun enableInteractiveInlineButtons(): Boolean = false + override fun enableInteropViewManagerClassLookUpOptimizationIOS(): Boolean = false override fun enableIntersectionObserverByDefault(): Boolean = false diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt index a8c03ed6efdb..bf31d16f4cbc 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt @@ -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<<755f4d7a47ce52392948a9c60f73afa6>> */ /** @@ -64,6 +64,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc private var enableImperativeEventsCache: Boolean? = null private var enableImperativeFocusCache: Boolean? = null private var enableInteractableResponderViewsCache: Boolean? = null + private var enableInteractiveInlineButtonsCache: Boolean? = null private var enableInteropViewManagerClassLookUpOptimizationIOSCache: Boolean? = null private var enableIntersectionObserverByDefaultCache: Boolean? = null private var enableKeyEventsCache: Boolean? = null @@ -528,6 +529,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc return cached } + override fun enableInteractiveInlineButtons(): Boolean { + var cached = enableInteractiveInlineButtonsCache + if (cached == null) { + cached = currentProvider.enableInteractiveInlineButtons() + accessedFeatureFlags.add("enableInteractiveInlineButtons") + enableInteractiveInlineButtonsCache = cached + } + return cached + } + override fun enableInteropViewManagerClassLookUpOptimizationIOS(): Boolean { var cached = enableInteropViewManagerClassLookUpOptimizationIOSCache if (cached == null) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt index 25d1defa538f..69eda5612822 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt @@ -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<<43bf244bab835c8890910c4e3d00bdec>> */ /** @@ -103,6 +103,8 @@ public interface ReactNativeFeatureFlagsProvider { @DoNotStrip public fun enableInteractableResponderViews(): Boolean + @DoNotStrip public fun enableInteractiveInlineButtons(): Boolean + @DoNotStrip public fun enableInteropViewManagerClassLookUpOptimizationIOS(): Boolean @DoNotStrip public fun enableIntersectionObserverByDefault(): Boolean diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.kt index f81d19849ea1..9f1a798a5fd2 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.kt @@ -300,6 +300,21 @@ internal object TextLayoutManager { } } + private fun isInlineInteractiveRole( + role: ReactAccessibilityDelegate.Role?, + accessibilityRole: ReactAccessibilityDelegate.AccessibilityRole?, + ): Boolean { + val effectiveRole = + if (role != null) ReactAccessibilityDelegate.AccessibilityRole.fromRole(role) + else accessibilityRole + return when (effectiveRole) { + ReactAccessibilityDelegate.AccessibilityRole.LINK -> true + ReactAccessibilityDelegate.AccessibilityRole.BUTTON -> + ReactNativeFeatureFlags.enableInteractiveInlineButtons() + else -> false + } + } + @OptIn(UnstableReactNativeAPI::class) private fun buildSpannableFromFragments( assets: AssetManager, @@ -353,13 +368,7 @@ internal object TextLayoutManager { ), ) } else if (end >= start) { - val roleIsLink = - if (textAttributes.role != null) - (textAttributes.role == ReactAccessibilityDelegate.Role.LINK) - else - (textAttributes.accessibilityRole == - ReactAccessibilityDelegate.AccessibilityRole.LINK) - if (roleIsLink) { + if (isInlineInteractiveRole(textAttributes.role, textAttributes.accessibilityRole)) { if (ReactNativeFeatureFlags.enablePreparedTextLayout()) { ops.add(SetSpanOperation(start, end, ReactLinkSpan(i))) } else { @@ -591,14 +600,7 @@ internal object TextLayoutManager { spanFlags, ) } else { - val roleIsLink = - if (fragment.props.role != null) - (fragment.props.role == ReactAccessibilityDelegate.Role.LINK) - else - (fragment.props.accessibilityRole == - ReactAccessibilityDelegate.AccessibilityRole.LINK) - - if (roleIsLink) { + if (isInlineInteractiveRole(fragment.props.role, fragment.props.accessibilityRole)) { if (ReactNativeFeatureFlags.enablePreparedTextLayout()) { spannable.setSpan(ReactLinkSpan(i), start, end, spanFlags) } else { diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp index f31a45aaa22f..e48d537995c1 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp @@ -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<<927c12777b5682e200477286b49fa8dd>> + * @generated SignedSource<<26984d266b1f68d96ace6c23903b9d4a>> */ /** @@ -279,6 +279,12 @@ class ReactNativeFeatureFlagsJavaProvider return method(javaProvider_); } + bool enableInteractiveInlineButtons() override { + static const auto method = + getReactNativeFeatureFlagsProviderJavaClass()->getMethod("enableInteractiveInlineButtons"); + return method(javaProvider_); + } + bool enableInteropViewManagerClassLookUpOptimizationIOS() override { static const auto method = getReactNativeFeatureFlagsProviderJavaClass()->getMethod("enableInteropViewManagerClassLookUpOptimizationIOS"); @@ -861,6 +867,11 @@ bool JReactNativeFeatureFlagsCxxInterop::enableInteractableResponderViews( return ReactNativeFeatureFlags::enableInteractableResponderViews(); } +bool JReactNativeFeatureFlagsCxxInterop::enableInteractiveInlineButtons( + facebook::jni::alias_ref /*unused*/) { + return ReactNativeFeatureFlags::enableInteractiveInlineButtons(); +} + bool JReactNativeFeatureFlagsCxxInterop::enableInteropViewManagerClassLookUpOptimizationIOS( facebook::jni::alias_ref /*unused*/) { return ReactNativeFeatureFlags::enableInteropViewManagerClassLookUpOptimizationIOS(); @@ -1327,6 +1338,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() { makeNativeMethod( "enableInteractableResponderViews", JReactNativeFeatureFlagsCxxInterop::enableInteractableResponderViews), + makeNativeMethod( + "enableInteractiveInlineButtons", + JReactNativeFeatureFlagsCxxInterop::enableInteractiveInlineButtons), makeNativeMethod( "enableInteropViewManagerClassLookUpOptimizationIOS", JReactNativeFeatureFlagsCxxInterop::enableInteropViewManagerClassLookUpOptimizationIOS), diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h b/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h index 46951834aead..03499ca2d992 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h +++ b/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h @@ -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<<079a6bc867f6eeace870efaf80e20f75>> + * @generated SignedSource<> */ /** @@ -150,6 +150,9 @@ class JReactNativeFeatureFlagsCxxInterop static bool enableInteractableResponderViews( facebook::jni::alias_ref); + static bool enableInteractiveInlineButtons( + facebook::jni::alias_ref); + static bool enableInteropViewManagerClassLookUpOptimizationIOS( facebook::jni::alias_ref); diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/text/TextLayoutManagerInlineButtonTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/text/TextLayoutManagerInlineButtonTest.kt new file mode 100644 index 000000000000..2c4150d16464 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/text/TextLayoutManagerInlineButtonTest.kt @@ -0,0 +1,270 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +package com.facebook.react.views.text + +import android.text.Spannable +import android.text.style.ClickableSpan +import com.facebook.react.common.annotations.UnstableReactNativeAPI +import com.facebook.react.common.mapbuffer.MapBuffer +import com.facebook.react.common.mapbuffer.ReadableMapBuffer +import com.facebook.react.common.mapbuffer.WritableMapBuffer +import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags +import com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsDefaults +import com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsForTests +import com.facebook.react.uimanager.DisplayMetricsHolder +import com.facebook.react.uimanager.ReactAccessibilityDelegate.Role +import com.facebook.react.views.text.internal.span.ReactClickableSpan +import com.facebook.react.views.text.internal.span.ReactLinkSpan +import com.facebook.testutils.shadows.ShadowNativeLoader +import com.facebook.yoga.YogaMeasureMode +import org.assertj.core.api.Assertions.assertThat +import org.junit.After +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.AdditionalAnswers.delegatesTo +import org.mockito.Mockito.doReturn +import org.mockito.Mockito.mock +import org.robolectric.ParameterizedRobolectricTestRunner +import org.robolectric.RuntimeEnvironment +import org.robolectric.annotation.Config + +@OptIn(UnstableReactNativeAPI::class) +@RunWith(ParameterizedRobolectricTestRunner::class) +@Config(sdk = [34], shadows = [ShadowNativeLoader::class]) +class TextLayoutManagerInlineButtonTest( + private val optimized: Boolean, + private val prepared: Boolean, +) { + private var buttonsEnabled = true + private var preparedLayout: PreparedLayout? = null + + @Before + fun setUp() { + buttonsEnabled = true + preparedLayout = null + ReactNativeFeatureFlagsForTests.setUp() + ReactNativeFeatureFlags.override( + object : ReactNativeFeatureFlagsDefaults() { + override fun enableInteractiveInlineButtons(): Boolean = buttonsEnabled + + override fun enableAndroidTextMeasurementOptimizations(): Boolean = optimized + + override fun enablePreparedTextLayout(): Boolean = prepared + }, + ) + DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(RuntimeEnvironment.getApplication()) + } + + @After + fun tearDown() { + DisplayMetricsHolder.setScreenDisplayMetrics(null) + ReactNativeFeatureFlags.dangerouslyReset() + } + + @Test + fun `role=button produces a clickable span`() { + assertInteractive(attributes(role = Role.BUTTON)) + } + + @Test + fun `accessibilityRole=button produces a clickable span`() { + assertInteractive(attributes(accessibilityRole = "button")) + } + + @Test + fun `role=link produces a clickable span`() { + assertInteractive(attributes(role = Role.LINK)) + } + + @Test + fun `accessibilityRole=link produces a clickable span`() { + assertInteractive(attributes(accessibilityRole = "link")) + } + + @Test + fun `disabled flag preserves links`() { + buttonsEnabled = false + assertInteractive(attributes(role = Role.LINK)) + assertInteractive(attributes(accessibilityRole = "link")) + } + + @Test + fun `disabled flag leaves role buttons without clickable spans`() { + buttonsEnabled = false + assertNotInteractive(attributes(role = Role.BUTTON)) + } + + @Test + fun `disabled flag leaves accessibilityRole buttons without clickable spans`() { + buttonsEnabled = false + assertNotInteractive(attributes(accessibilityRole = "button")) + } + + @Test + fun `explicit heading role overrides accessibilityRole link`() { + assertNotInteractive(attributes(role = Role.HEADING, accessibilityRole = "link")) + } + + @Test + fun `explicit link role overrides accessibilityRole button`() { + buttonsEnabled = false + assertInteractive(attributes(role = Role.LINK, accessibilityRole = "button")) + } + + @Test + fun `explicit button role overrides accessibilityRole link when flag is disabled`() { + buttonsEnabled = false + assertNotInteractive(attributes(role = Role.BUTTON, accessibilityRole = "link")) + } + + @Test + fun `plain text does not produce clickable spans`() { + assertNotInteractive(attributes()) + } + + @Test + fun `clickable spans keep fragment bounds and tag mapping`() { + val text = + build( + fragment("Author ", 13), + fragment("Follow", 42, attributes(role = Role.BUTTON)), + fragment(" and ", 87), + fragment("Profile", 99, attributes(accessibilityRole = "link")), + fragment(".", 103), + ) + val spans = clickableSpans(text) + assertThat(text.toString()).isEqualTo("Author Follow and Profile.") + assertThat(spans).hasSize(2) + assertSpan(text, spans[0], 7, 13, 1, 42) + assertSpan(text, spans[1], 18, 25, 3, 99) + if (prepared) { + assertThat(checkNotNull(preparedLayout).reactTags).containsExactly(13, 42, 87, 99, 103) + } + } + + @Test + fun `span creation keeps the declared button role`() { + val attrs = attributes(role = Role.BUTTON) + assertInteractive(attrs) + assertThat(TextAttributeProps.fromMapBuffer(attrs).role).isEqualTo(Role.BUTTON) + } + + @Test + fun `inline attachments do not become clickable spans`() { + val attachment = + fragment("\uFFFC", 42, attributes(role = Role.BUTTON)) + .put(TextLayoutManager.FR_KEY_IS_ATTACHMENT, true) + .put(TextLayoutManager.FR_KEY_WIDTH, 10.0) + .put(TextLayoutManager.FR_KEY_HEIGHT, 10.0) + assertThat(clickableSpans(build(attachment))).isEmpty() + } + + private fun attributes(role: Role? = null, accessibilityRole: String? = null): WritableMapBuffer = + WritableMapBuffer().apply { + put(TextAttributeProps.TA_KEY_FONT_SIZE, 16.0) + role?.let { put(TextAttributeProps.TA_KEY_ROLE, it.ordinal) } + accessibilityRole?.let { put(TextAttributeProps.TA_KEY_ACCESSIBILITY_ROLE, it) } + } + + private fun fragment( + text: String, + tag: Int, + attrs: WritableMapBuffer = attributes(), + ): WritableMapBuffer = + WritableMapBuffer() + .put(TextLayoutManager.FR_KEY_STRING, text) + .put(TextLayoutManager.FR_KEY_REACT_TAG, tag) + .put(TextLayoutManager.FR_KEY_TEXT_ATTRIBUTES, attrs) + + private fun build(vararg fragments: WritableMapBuffer): Spannable { + val fragmentMap = WritableMapBuffer() + fragments.forEachIndexed { index, fragment -> fragmentMap.put(index, fragment) } + val attributedString = + WritableMapBuffer() + .put(TextLayoutManager.AS_KEY_FRAGMENTS, fragmentMap) + .put(TextLayoutManager.AS_KEY_BASE_ATTRIBUTES, attributes()) + val assets = RuntimeEnvironment.getApplication().assets + if (!prepared) { + return TextLayoutManager.getOrCreateSpannableForText(assets, attributedString, null) + } + val layout = + TextLayoutManager.createPreparedLayout( + assets, + readable(attributedString), + readable( + WritableMapBuffer() + .put(TextLayoutManager.PA_KEY_TEXT_BREAK_STRATEGY, "highQuality") + .put(TextLayoutManager.PA_KEY_HYPHENATION_FREQUENCY, "none"), + ), + 300f, + YogaMeasureMode.EXACTLY, + Float.NaN, + YogaMeasureMode.UNDEFINED, + null, + ) + preparedLayout = layout + return layout.sourceText as Spannable + } + + private fun readable(buffer: MapBuffer): ReadableMapBuffer { + val result = mock(ReadableMapBuffer::class.java, delegatesTo(buffer)) + for (entry in buffer) { + if (entry.type == MapBuffer.DataType.MAP) { + doReturn(readable(entry.mapBufferValue)).`when`(result).getMapBuffer(entry.key) + } + } + return result + } + + private fun clickableSpans(text: Spannable): List = + text.getSpans(0, text.length, ClickableSpan::class.java).sortedBy { text.getSpanStart(it) } + + private fun assertInteractive(attrs: WritableMapBuffer) { + val text = build(fragment("Follow", 42, attrs)) + val spans = clickableSpans(text) + assertThat(spans).hasSize(1) + assertSpan(text, spans.single(), 0, 6, 0, 42) + } + + private fun assertNotInteractive(attrs: WritableMapBuffer) { + assertThat(clickableSpans(build(fragment("Follow", 42, attrs)))).isEmpty() + } + + private fun assertSpan( + text: Spannable, + span: ClickableSpan, + start: Int, + end: Int, + fragmentIndex: Int, + tag: Int, + ) { + assertThat(text.getSpanStart(span)).isEqualTo(start) + assertThat(text.getSpanEnd(span)).isEqualTo(end) + if (prepared) { + assertThat(span).isInstanceOf(ReactLinkSpan::class.java) + assertThat((span as ReactLinkSpan).fragmentIndex).isEqualTo(fragmentIndex) + assertThat(checkNotNull(preparedLayout).reactTags[span.fragmentIndex]).isEqualTo(tag) + } else { + assertThat(span).isInstanceOf(ReactClickableSpan::class.java) + assertThat((span as ReactClickableSpan).reactTag).isEqualTo(tag) + } + } + + companion object { + @JvmStatic + @ParameterizedRobolectricTestRunner.Parameters(name = "optimized={0}, prepared={1}") + fun parameters(): List> = + listOf( + arrayOf(false, false), + arrayOf(false, true), + arrayOf(true, false), + arrayOf(true, true), + ) + } +} diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp index 101e2ff938b6..c58f6edaaa6d 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp @@ -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<<7a02d21afc37beb9618eb31d5ae5a15c>> + * @generated SignedSource<> */ /** @@ -186,6 +186,10 @@ bool ReactNativeFeatureFlags::enableInteractableResponderViews() { return getAccessor().enableInteractableResponderViews(); } +bool ReactNativeFeatureFlags::enableInteractiveInlineButtons() { + return getAccessor().enableInteractiveInlineButtons(); +} + bool ReactNativeFeatureFlags::enableInteropViewManagerClassLookUpOptimizationIOS() { return getAccessor().enableInteropViewManagerClassLookUpOptimizationIOS(); } diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h index 8ec2bdb97939..378f38145535 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h @@ -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<<61b669719ed341332652257d1353fbe6>> + * @generated SignedSource<> */ /** @@ -241,6 +241,11 @@ class ReactNativeFeatureFlags { */ RN_EXPORT static bool enableInteractableResponderViews(); + /** + * When enabled, inline text with a button role produces a ClickableSpan (like a link). + */ + RN_EXPORT static bool enableInteractiveInlineButtons(); + /** * This is to fix the issue with interop view manager where component descriptor lookup is causing ViewManager to preload. */ diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp index 085489c4933a..078137cf33e5 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp @@ -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<<2b7f04735e2bf40dd1b2a1258c5c1bc1>> + * @generated SignedSource<<677d234806ae5ffea9d2f4bb4f8fef8f>> */ /** @@ -749,6 +749,24 @@ bool ReactNativeFeatureFlagsAccessor::enableInteractableResponderViews() { return flagValue.value(); } +bool ReactNativeFeatureFlagsAccessor::enableInteractiveInlineButtons() { + auto flagValue = enableInteractiveInlineButtons_.load(); + + if (!flagValue.has_value()) { + // This block is not exclusive but it is not necessary. + // If multiple threads try to initialize the feature flag, we would only + // be accessing the provider multiple times but the end state of this + // instance and the returned flag value would be the same. + + markFlagAsAccessed(40, "enableInteractiveInlineButtons"); + + flagValue = currentProvider_->enableInteractiveInlineButtons(); + enableInteractiveInlineButtons_ = flagValue; + } + + return flagValue.value(); +} + bool ReactNativeFeatureFlagsAccessor::enableInteropViewManagerClassLookUpOptimizationIOS() { auto flagValue = enableInteropViewManagerClassLookUpOptimizationIOS_.load(); @@ -758,7 +776,7 @@ bool ReactNativeFeatureFlagsAccessor::enableInteropViewManagerClassLookUpOptimiz // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(40, "enableInteropViewManagerClassLookUpOptimizationIOS"); + markFlagAsAccessed(41, "enableInteropViewManagerClassLookUpOptimizationIOS"); flagValue = currentProvider_->enableInteropViewManagerClassLookUpOptimizationIOS(); enableInteropViewManagerClassLookUpOptimizationIOS_ = flagValue; @@ -776,7 +794,7 @@ bool ReactNativeFeatureFlagsAccessor::enableIntersectionObserverByDefault() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(41, "enableIntersectionObserverByDefault"); + markFlagAsAccessed(42, "enableIntersectionObserverByDefault"); flagValue = currentProvider_->enableIntersectionObserverByDefault(); enableIntersectionObserverByDefault_ = flagValue; @@ -794,7 +812,7 @@ bool ReactNativeFeatureFlagsAccessor::enableKeyEvents() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(42, "enableKeyEvents"); + markFlagAsAccessed(43, "enableKeyEvents"); flagValue = currentProvider_->enableKeyEvents(); enableKeyEvents_ = flagValue; @@ -812,7 +830,7 @@ bool ReactNativeFeatureFlagsAccessor::enableLayoutAnimationsOnAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(43, "enableLayoutAnimationsOnAndroid"); + markFlagAsAccessed(44, "enableLayoutAnimationsOnAndroid"); flagValue = currentProvider_->enableLayoutAnimationsOnAndroid(); enableLayoutAnimationsOnAndroid_ = flagValue; @@ -830,7 +848,7 @@ bool ReactNativeFeatureFlagsAccessor::enableLayoutAnimationsOnIOS() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(44, "enableLayoutAnimationsOnIOS"); + markFlagAsAccessed(45, "enableLayoutAnimationsOnIOS"); flagValue = currentProvider_->enableLayoutAnimationsOnIOS(); enableLayoutAnimationsOnIOS_ = flagValue; @@ -848,7 +866,7 @@ bool ReactNativeFeatureFlagsAccessor::enableModuleArgumentNSNullConversionIOS() // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(45, "enableModuleArgumentNSNullConversionIOS"); + markFlagAsAccessed(46, "enableModuleArgumentNSNullConversionIOS"); flagValue = currentProvider_->enableModuleArgumentNSNullConversionIOS(); enableModuleArgumentNSNullConversionIOS_ = flagValue; @@ -866,7 +884,7 @@ bool ReactNativeFeatureFlagsAccessor::enableMountingCoordinatorPullModelAndroid( // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(46, "enableMountingCoordinatorPullModelAndroid"); + markFlagAsAccessed(47, "enableMountingCoordinatorPullModelAndroid"); flagValue = currentProvider_->enableMountingCoordinatorPullModelAndroid(); enableMountingCoordinatorPullModelAndroid_ = flagValue; @@ -884,7 +902,7 @@ bool ReactNativeFeatureFlagsAccessor::enableMutationObserverByDefault() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(47, "enableMutationObserverByDefault"); + markFlagAsAccessed(48, "enableMutationObserverByDefault"); flagValue = currentProvider_->enableMutationObserverByDefault(); enableMutationObserverByDefault_ = flagValue; @@ -902,7 +920,7 @@ bool ReactNativeFeatureFlagsAccessor::enableNativeCSSParsing() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(48, "enableNativeCSSParsing"); + markFlagAsAccessed(49, "enableNativeCSSParsing"); flagValue = currentProvider_->enableNativeCSSParsing(); enableNativeCSSParsing_ = flagValue; @@ -920,7 +938,7 @@ bool ReactNativeFeatureFlagsAccessor::enablePreallocatedPropsDiffOnInsertAndroid // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(49, "enablePreallocatedPropsDiffOnInsertAndroid"); + markFlagAsAccessed(50, "enablePreallocatedPropsDiffOnInsertAndroid"); flagValue = currentProvider_->enablePreallocatedPropsDiffOnInsertAndroid(); enablePreallocatedPropsDiffOnInsertAndroid_ = flagValue; @@ -938,7 +956,7 @@ bool ReactNativeFeatureFlagsAccessor::enablePreparedTextLayout() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(50, "enablePreparedTextLayout"); + markFlagAsAccessed(51, "enablePreparedTextLayout"); flagValue = currentProvider_->enablePreparedTextLayout(); enablePreparedTextLayout_ = flagValue; @@ -956,7 +974,7 @@ bool ReactNativeFeatureFlagsAccessor::enablePropsUpdateReconciliationAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(51, "enablePropsUpdateReconciliationAndroid"); + markFlagAsAccessed(52, "enablePropsUpdateReconciliationAndroid"); flagValue = currentProvider_->enablePropsUpdateReconciliationAndroid(); enablePropsUpdateReconciliationAndroid_ = flagValue; @@ -974,7 +992,7 @@ bool ReactNativeFeatureFlagsAccessor::enableResizeObserverByDefault() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(52, "enableResizeObserverByDefault"); + markFlagAsAccessed(53, "enableResizeObserverByDefault"); flagValue = currentProvider_->enableResizeObserverByDefault(); enableResizeObserverByDefault_ = flagValue; @@ -992,7 +1010,7 @@ bool ReactNativeFeatureFlagsAccessor::enableSwiftUIBasedFilters() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(53, "enableSwiftUIBasedFilters"); + markFlagAsAccessed(54, "enableSwiftUIBasedFilters"); flagValue = currentProvider_->enableSwiftUIBasedFilters(); enableSwiftUIBasedFilters_ = flagValue; @@ -1010,7 +1028,7 @@ bool ReactNativeFeatureFlagsAccessor::enableViewCulling() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(54, "enableViewCulling"); + markFlagAsAccessed(55, "enableViewCulling"); flagValue = currentProvider_->enableViewCulling(); enableViewCulling_ = flagValue; @@ -1028,7 +1046,7 @@ bool ReactNativeFeatureFlagsAccessor::enableViewRecycling() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(55, "enableViewRecycling"); + markFlagAsAccessed(56, "enableViewRecycling"); flagValue = currentProvider_->enableViewRecycling(); enableViewRecycling_ = flagValue; @@ -1046,7 +1064,7 @@ bool ReactNativeFeatureFlagsAccessor::enableViewRecyclingForImage() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(56, "enableViewRecyclingForImage"); + markFlagAsAccessed(57, "enableViewRecyclingForImage"); flagValue = currentProvider_->enableViewRecyclingForImage(); enableViewRecyclingForImage_ = flagValue; @@ -1064,7 +1082,7 @@ bool ReactNativeFeatureFlagsAccessor::enableViewRecyclingForScrollView() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(57, "enableViewRecyclingForScrollView"); + markFlagAsAccessed(58, "enableViewRecyclingForScrollView"); flagValue = currentProvider_->enableViewRecyclingForScrollView(); enableViewRecyclingForScrollView_ = flagValue; @@ -1082,7 +1100,7 @@ bool ReactNativeFeatureFlagsAccessor::enableViewRecyclingForText() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(58, "enableViewRecyclingForText"); + markFlagAsAccessed(59, "enableViewRecyclingForText"); flagValue = currentProvider_->enableViewRecyclingForText(); enableViewRecyclingForText_ = flagValue; @@ -1100,7 +1118,7 @@ bool ReactNativeFeatureFlagsAccessor::enableViewRecyclingForView() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(59, "enableViewRecyclingForView"); + markFlagAsAccessed(60, "enableViewRecyclingForView"); flagValue = currentProvider_->enableViewRecyclingForView(); enableViewRecyclingForView_ = flagValue; @@ -1118,7 +1136,7 @@ bool ReactNativeFeatureFlagsAccessor::enableVirtualViewContainerStateExperimenta // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(60, "enableVirtualViewContainerStateExperimental"); + markFlagAsAccessed(61, "enableVirtualViewContainerStateExperimental"); flagValue = currentProvider_->enableVirtualViewContainerStateExperimental(); enableVirtualViewContainerStateExperimental_ = flagValue; @@ -1136,7 +1154,7 @@ bool ReactNativeFeatureFlagsAccessor::fixBorderlessRippleAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(61, "fixBorderlessRippleAndroid"); + markFlagAsAccessed(62, "fixBorderlessRippleAndroid"); flagValue = currentProvider_->fixBorderlessRippleAndroid(); fixBorderlessRippleAndroid_ = flagValue; @@ -1154,7 +1172,7 @@ bool ReactNativeFeatureFlagsAccessor::fixMappingOfEventPrioritiesBetweenFabricAn // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(62, "fixMappingOfEventPrioritiesBetweenFabricAndReact"); + markFlagAsAccessed(63, "fixMappingOfEventPrioritiesBetweenFabricAndReact"); flagValue = currentProvider_->fixMappingOfEventPrioritiesBetweenFabricAndReact(); fixMappingOfEventPrioritiesBetweenFabricAndReact_ = flagValue; @@ -1172,7 +1190,7 @@ bool ReactNativeFeatureFlagsAccessor::fixMultilineContentJumpAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(63, "fixMultilineContentJumpAndroid"); + markFlagAsAccessed(64, "fixMultilineContentJumpAndroid"); flagValue = currentProvider_->fixMultilineContentJumpAndroid(); fixMultilineContentJumpAndroid_ = flagValue; @@ -1190,7 +1208,7 @@ bool ReactNativeFeatureFlagsAccessor::fixProgrammaticScrollMomentumEventsIOS() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(64, "fixProgrammaticScrollMomentumEventsIOS"); + markFlagAsAccessed(65, "fixProgrammaticScrollMomentumEventsIOS"); flagValue = currentProvider_->fixProgrammaticScrollMomentumEventsIOS(); fixProgrammaticScrollMomentumEventsIOS_ = flagValue; @@ -1208,7 +1226,7 @@ bool ReactNativeFeatureFlagsAccessor::fixTextInlineViewLineHeight() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(65, "fixTextInlineViewLineHeight"); + markFlagAsAccessed(66, "fixTextInlineViewLineHeight"); flagValue = currentProvider_->fixTextInlineViewLineHeight(); fixTextInlineViewLineHeight_ = flagValue; @@ -1226,7 +1244,7 @@ bool ReactNativeFeatureFlagsAccessor::fixTextLayoutOnPixelDensityChange() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(66, "fixTextLayoutOnPixelDensityChange"); + markFlagAsAccessed(67, "fixTextLayoutOnPixelDensityChange"); flagValue = currentProvider_->fixTextLayoutOnPixelDensityChange(); fixTextLayoutOnPixelDensityChange_ = flagValue; @@ -1244,7 +1262,7 @@ bool ReactNativeFeatureFlagsAccessor::fixYogaFlexBasisFitContentInMainAxis() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(67, "fixYogaFlexBasisFitContentInMainAxis"); + markFlagAsAccessed(68, "fixYogaFlexBasisFitContentInMainAxis"); flagValue = currentProvider_->fixYogaFlexBasisFitContentInMainAxis(); fixYogaFlexBasisFitContentInMainAxis_ = flagValue; @@ -1262,7 +1280,7 @@ bool ReactNativeFeatureFlagsAccessor::fuseboxAssertSingleHostState() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(68, "fuseboxAssertSingleHostState"); + markFlagAsAccessed(69, "fuseboxAssertSingleHostState"); flagValue = currentProvider_->fuseboxAssertSingleHostState(); fuseboxAssertSingleHostState_ = flagValue; @@ -1280,7 +1298,7 @@ bool ReactNativeFeatureFlagsAccessor::fuseboxEnabledRelease() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(69, "fuseboxEnabledRelease"); + markFlagAsAccessed(70, "fuseboxEnabledRelease"); flagValue = currentProvider_->fuseboxEnabledRelease(); fuseboxEnabledRelease_ = flagValue; @@ -1298,7 +1316,7 @@ bool ReactNativeFeatureFlagsAccessor::fuseboxFrameRecordingEnabled() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(70, "fuseboxFrameRecordingEnabled"); + markFlagAsAccessed(71, "fuseboxFrameRecordingEnabled"); flagValue = currentProvider_->fuseboxFrameRecordingEnabled(); fuseboxFrameRecordingEnabled_ = flagValue; @@ -1316,7 +1334,7 @@ bool ReactNativeFeatureFlagsAccessor::fuseboxScreenshotCaptureEnabled() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(71, "fuseboxScreenshotCaptureEnabled"); + markFlagAsAccessed(72, "fuseboxScreenshotCaptureEnabled"); flagValue = currentProvider_->fuseboxScreenshotCaptureEnabled(); fuseboxScreenshotCaptureEnabled_ = flagValue; @@ -1334,7 +1352,7 @@ bool ReactNativeFeatureFlagsAccessor::fuseboxWebSocketEventsEnabled() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(72, "fuseboxWebSocketEventsEnabled"); + markFlagAsAccessed(73, "fuseboxWebSocketEventsEnabled"); flagValue = currentProvider_->fuseboxWebSocketEventsEnabled(); fuseboxWebSocketEventsEnabled_ = flagValue; @@ -1352,7 +1370,7 @@ bool ReactNativeFeatureFlagsAccessor::keepTimersRunningWhileHostPausedAndroid() // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(73, "keepTimersRunningWhileHostPausedAndroid"); + markFlagAsAccessed(74, "keepTimersRunningWhileHostPausedAndroid"); flagValue = currentProvider_->keepTimersRunningWhileHostPausedAndroid(); keepTimersRunningWhileHostPausedAndroid_ = flagValue; @@ -1370,7 +1388,7 @@ bool ReactNativeFeatureFlagsAccessor::optimizedAnimatedPropUpdates() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(74, "optimizedAnimatedPropUpdates"); + markFlagAsAccessed(75, "optimizedAnimatedPropUpdates"); flagValue = currentProvider_->optimizedAnimatedPropUpdates(); optimizedAnimatedPropUpdates_ = flagValue; @@ -1388,7 +1406,7 @@ bool ReactNativeFeatureFlagsAccessor::overrideBySynchronousMountPropsAtMountingA // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(75, "overrideBySynchronousMountPropsAtMountingAndroid"); + markFlagAsAccessed(76, "overrideBySynchronousMountPropsAtMountingAndroid"); flagValue = currentProvider_->overrideBySynchronousMountPropsAtMountingAndroid(); overrideBySynchronousMountPropsAtMountingAndroid_ = flagValue; @@ -1406,7 +1424,7 @@ bool ReactNativeFeatureFlagsAccessor::perfIssuesEnabled() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(76, "perfIssuesEnabled"); + markFlagAsAccessed(77, "perfIssuesEnabled"); flagValue = currentProvider_->perfIssuesEnabled(); perfIssuesEnabled_ = flagValue; @@ -1424,7 +1442,7 @@ bool ReactNativeFeatureFlagsAccessor::perfMonitorV2Enabled() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(77, "perfMonitorV2Enabled"); + markFlagAsAccessed(78, "perfMonitorV2Enabled"); flagValue = currentProvider_->perfMonitorV2Enabled(); perfMonitorV2Enabled_ = flagValue; @@ -1442,7 +1460,7 @@ double ReactNativeFeatureFlagsAccessor::preparedTextCacheSize() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(78, "preparedTextCacheSize"); + markFlagAsAccessed(79, "preparedTextCacheSize"); flagValue = currentProvider_->preparedTextCacheSize(); preparedTextCacheSize_ = flagValue; @@ -1460,7 +1478,7 @@ bool ReactNativeFeatureFlagsAccessor::preventShadowTreeCommitExhaustion() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(79, "preventShadowTreeCommitExhaustion"); + markFlagAsAccessed(80, "preventShadowTreeCommitExhaustion"); flagValue = currentProvider_->preventShadowTreeCommitExhaustion(); preventShadowTreeCommitExhaustion_ = flagValue; @@ -1478,7 +1496,7 @@ bool ReactNativeFeatureFlagsAccessor::redBoxV2Android() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(80, "redBoxV2Android"); + markFlagAsAccessed(81, "redBoxV2Android"); flagValue = currentProvider_->redBoxV2Android(); redBoxV2Android_ = flagValue; @@ -1496,7 +1514,7 @@ bool ReactNativeFeatureFlagsAccessor::redBoxV2IOS() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(81, "redBoxV2IOS"); + markFlagAsAccessed(82, "redBoxV2IOS"); flagValue = currentProvider_->redBoxV2IOS(); redBoxV2IOS_ = flagValue; @@ -1514,7 +1532,7 @@ bool ReactNativeFeatureFlagsAccessor::shouldPressibilityUseW3CPointerEventsForHo // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(82, "shouldPressibilityUseW3CPointerEventsForHover"); + markFlagAsAccessed(83, "shouldPressibilityUseW3CPointerEventsForHover"); flagValue = currentProvider_->shouldPressibilityUseW3CPointerEventsForHover(); shouldPressibilityUseW3CPointerEventsForHover_ = flagValue; @@ -1532,7 +1550,7 @@ bool ReactNativeFeatureFlagsAccessor::shouldTriggerResponderTransferOnScrollAndr // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(83, "shouldTriggerResponderTransferOnScrollAndroid"); + markFlagAsAccessed(84, "shouldTriggerResponderTransferOnScrollAndroid"); flagValue = currentProvider_->shouldTriggerResponderTransferOnScrollAndroid(); shouldTriggerResponderTransferOnScrollAndroid_ = flagValue; @@ -1550,7 +1568,7 @@ bool ReactNativeFeatureFlagsAccessor::skipActivityIdentityAssertionOnHostPause() // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(84, "skipActivityIdentityAssertionOnHostPause"); + markFlagAsAccessed(85, "skipActivityIdentityAssertionOnHostPause"); flagValue = currentProvider_->skipActivityIdentityAssertionOnHostPause(); skipActivityIdentityAssertionOnHostPause_ = flagValue; @@ -1568,7 +1586,7 @@ bool ReactNativeFeatureFlagsAccessor::skipNativePropsForViewManagerWithDelegateA // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(85, "skipNativePropsForViewManagerWithDelegateAndroid"); + markFlagAsAccessed(86, "skipNativePropsForViewManagerWithDelegateAndroid"); flagValue = currentProvider_->skipNativePropsForViewManagerWithDelegateAndroid(); skipNativePropsForViewManagerWithDelegateAndroid_ = flagValue; @@ -1586,7 +1604,7 @@ bool ReactNativeFeatureFlagsAccessor::skipUnchangedChildrenInDifferentiator() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(86, "skipUnchangedChildrenInDifferentiator"); + markFlagAsAccessed(87, "skipUnchangedChildrenInDifferentiator"); flagValue = currentProvider_->skipUnchangedChildrenInDifferentiator(); skipUnchangedChildrenInDifferentiator_ = flagValue; @@ -1604,7 +1622,7 @@ bool ReactNativeFeatureFlagsAccessor::syncAndroidClipBoundsWithOverflow() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(87, "syncAndroidClipBoundsWithOverflow"); + markFlagAsAccessed(88, "syncAndroidClipBoundsWithOverflow"); flagValue = currentProvider_->syncAndroidClipBoundsWithOverflow(); syncAndroidClipBoundsWithOverflow_ = flagValue; @@ -1622,7 +1640,7 @@ bool ReactNativeFeatureFlagsAccessor::traceTurboModulePromiseRejectionsOnAndroid // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(88, "traceTurboModulePromiseRejectionsOnAndroid"); + markFlagAsAccessed(89, "traceTurboModulePromiseRejectionsOnAndroid"); flagValue = currentProvider_->traceTurboModulePromiseRejectionsOnAndroid(); traceTurboModulePromiseRejectionsOnAndroid_ = flagValue; @@ -1640,7 +1658,7 @@ bool ReactNativeFeatureFlagsAccessor::updateRuntimeShadowNodeReferencesOnCommit( // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(89, "updateRuntimeShadowNodeReferencesOnCommit"); + markFlagAsAccessed(90, "updateRuntimeShadowNodeReferencesOnCommit"); flagValue = currentProvider_->updateRuntimeShadowNodeReferencesOnCommit(); updateRuntimeShadowNodeReferencesOnCommit_ = flagValue; @@ -1658,7 +1676,7 @@ bool ReactNativeFeatureFlagsAccessor::updateRuntimeShadowNodeReferencesOnCommitT // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(90, "updateRuntimeShadowNodeReferencesOnCommitThread"); + markFlagAsAccessed(91, "updateRuntimeShadowNodeReferencesOnCommitThread"); flagValue = currentProvider_->updateRuntimeShadowNodeReferencesOnCommitThread(); updateRuntimeShadowNodeReferencesOnCommitThread_ = flagValue; @@ -1676,7 +1694,7 @@ bool ReactNativeFeatureFlagsAccessor::useAlwaysAvailableJSErrorHandling() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(91, "useAlwaysAvailableJSErrorHandling"); + markFlagAsAccessed(92, "useAlwaysAvailableJSErrorHandling"); flagValue = currentProvider_->useAlwaysAvailableJSErrorHandling(); useAlwaysAvailableJSErrorHandling_ = flagValue; @@ -1694,7 +1712,7 @@ bool ReactNativeFeatureFlagsAccessor::useFabricInterop() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(92, "useFabricInterop"); + markFlagAsAccessed(93, "useFabricInterop"); flagValue = currentProvider_->useFabricInterop(); useFabricInterop_ = flagValue; @@ -1712,7 +1730,7 @@ bool ReactNativeFeatureFlagsAccessor::useNativeViewConfigsInBridgelessMode() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(93, "useNativeViewConfigsInBridgelessMode"); + markFlagAsAccessed(94, "useNativeViewConfigsInBridgelessMode"); flagValue = currentProvider_->useNativeViewConfigsInBridgelessMode(); useNativeViewConfigsInBridgelessMode_ = flagValue; @@ -1730,7 +1748,7 @@ bool ReactNativeFeatureFlagsAccessor::useNestedScrollViewAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(94, "useNestedScrollViewAndroid"); + markFlagAsAccessed(95, "useNestedScrollViewAndroid"); flagValue = currentProvider_->useNestedScrollViewAndroid(); useNestedScrollViewAndroid_ = flagValue; @@ -1748,7 +1766,7 @@ bool ReactNativeFeatureFlagsAccessor::useSharedAnimatedBackend() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(95, "useSharedAnimatedBackend"); + markFlagAsAccessed(96, "useSharedAnimatedBackend"); flagValue = currentProvider_->useSharedAnimatedBackend(); useSharedAnimatedBackend_ = flagValue; @@ -1766,7 +1784,7 @@ bool ReactNativeFeatureFlagsAccessor::useTraitHiddenOnAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(96, "useTraitHiddenOnAndroid"); + markFlagAsAccessed(97, "useTraitHiddenOnAndroid"); flagValue = currentProvider_->useTraitHiddenOnAndroid(); useTraitHiddenOnAndroid_ = flagValue; @@ -1784,7 +1802,7 @@ bool ReactNativeFeatureFlagsAccessor::useTurboModuleInterop() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(97, "useTurboModuleInterop"); + markFlagAsAccessed(98, "useTurboModuleInterop"); flagValue = currentProvider_->useTurboModuleInterop(); useTurboModuleInterop_ = flagValue; @@ -1802,7 +1820,7 @@ bool ReactNativeFeatureFlagsAccessor::useWindowDensityForDisplayMetricsAndroid() // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(98, "useWindowDensityForDisplayMetricsAndroid"); + markFlagAsAccessed(99, "useWindowDensityForDisplayMetricsAndroid"); flagValue = currentProvider_->useWindowDensityForDisplayMetricsAndroid(); useWindowDensityForDisplayMetricsAndroid_ = flagValue; @@ -1820,7 +1838,7 @@ double ReactNativeFeatureFlagsAccessor::viewCullingOutsetRatio() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(99, "viewCullingOutsetRatio"); + markFlagAsAccessed(100, "viewCullingOutsetRatio"); flagValue = currentProvider_->viewCullingOutsetRatio(); viewCullingOutsetRatio_ = flagValue; @@ -1838,7 +1856,7 @@ bool ReactNativeFeatureFlagsAccessor::viewTransitionEnabled() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(100, "viewTransitionEnabled"); + markFlagAsAccessed(101, "viewTransitionEnabled"); flagValue = currentProvider_->viewTransitionEnabled(); viewTransitionEnabled_ = flagValue; @@ -1856,7 +1874,7 @@ bool ReactNativeFeatureFlagsAccessor::viewTransitionUseHardwareBitmapAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(101, "viewTransitionUseHardwareBitmapAndroid"); + markFlagAsAccessed(102, "viewTransitionUseHardwareBitmapAndroid"); flagValue = currentProvider_->viewTransitionUseHardwareBitmapAndroid(); viewTransitionUseHardwareBitmapAndroid_ = flagValue; @@ -1874,7 +1892,7 @@ double ReactNativeFeatureFlagsAccessor::virtualViewPrerenderRatio() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(102, "virtualViewPrerenderRatio"); + markFlagAsAccessed(103, "virtualViewPrerenderRatio"); flagValue = currentProvider_->virtualViewPrerenderRatio(); virtualViewPrerenderRatio_ = flagValue; diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h index 7c466521e287..617ff7c2e941 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h @@ -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<<7096d11fbd96554f62fb75e96fde616c>> + * @generated SignedSource<> */ /** @@ -74,6 +74,7 @@ class ReactNativeFeatureFlagsAccessor { bool enableImperativeEvents(); bool enableImperativeFocus(); bool enableInteractableResponderViews(); + bool enableInteractiveInlineButtons(); bool enableInteropViewManagerClassLookUpOptimizationIOS(); bool enableIntersectionObserverByDefault(); bool enableKeyEvents(); @@ -148,7 +149,7 @@ class ReactNativeFeatureFlagsAccessor { std::unique_ptr currentProvider_; bool wasOverridden_; - std::array, 103> accessedFeatureFlags_; + std::array, 104> accessedFeatureFlags_; std::atomic> commonTestFlag_; std::atomic> cdpInteractionMetricsEnabled_; @@ -190,6 +191,7 @@ class ReactNativeFeatureFlagsAccessor { std::atomic> enableImperativeEvents_; std::atomic> enableImperativeFocus_; std::atomic> enableInteractableResponderViews_; + std::atomic> enableInteractiveInlineButtons_; std::atomic> enableInteropViewManagerClassLookUpOptimizationIOS_; std::atomic> enableIntersectionObserverByDefault_; std::atomic> enableKeyEvents_; diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h index 1c0545cb3eed..f8890f7bb3b2 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h @@ -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<<52f0fb9dfb2f93024370c70ab96b6cc2>> + * @generated SignedSource<<412bae600285f2256f0b3cdd89b5efd3>> */ /** @@ -189,6 +189,10 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider { return false; } + bool enableInteractiveInlineButtons() override { + return false; + } + bool enableInteropViewManagerClassLookUpOptimizationIOS() override { return false; } diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h index f7c7de3e07ca..f04051659ddd 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h @@ -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<<76e14c6a936a9b48714eb423366701a8>> + * @generated SignedSource<<99a6c2c4b0c2bba1e9121caa2c7422bb>> */ /** @@ -407,6 +407,15 @@ class ReactNativeFeatureFlagsDynamicProvider : public ReactNativeFeatureFlagsDef return ReactNativeFeatureFlagsDefaults::enableInteractableResponderViews(); } + bool enableInteractiveInlineButtons() override { + auto value = values_["enableInteractiveInlineButtons"]; + if (!value.isNull()) { + return value.getBool(); + } + + return ReactNativeFeatureFlagsDefaults::enableInteractiveInlineButtons(); + } + bool enableInteropViewManagerClassLookUpOptimizationIOS() override { auto value = values_["enableInteropViewManagerClassLookUpOptimizationIOS"]; if (!value.isNull()) { diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h index ae888ac11e17..1e299981f6ad 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h @@ -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<<82bdceb1b4c5d209e7c01442e805f5b1>> + * @generated SignedSource<<3f72aa63daf55374f679ceacba510d99>> */ /** @@ -67,6 +67,7 @@ class ReactNativeFeatureFlagsProvider { virtual bool enableImperativeEvents() = 0; virtual bool enableImperativeFocus() = 0; virtual bool enableInteractableResponderViews() = 0; + virtual bool enableInteractiveInlineButtons() = 0; virtual bool enableInteropViewManagerClassLookUpOptimizationIOS() = 0; virtual bool enableIntersectionObserverByDefault() = 0; virtual bool enableKeyEvents() = 0; diff --git a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp index 758a185ec609..70b25f836ca4 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp +++ b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp @@ -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<<8b81d2bce675f8f83ffd82649c4dcad8>> + * @generated SignedSource<> */ /** @@ -244,6 +244,11 @@ bool NativeReactNativeFeatureFlags::enableInteractableResponderViews( return ReactNativeFeatureFlags::enableInteractableResponderViews(); } +bool NativeReactNativeFeatureFlags::enableInteractiveInlineButtons( + jsi::Runtime& /*runtime*/) { + return ReactNativeFeatureFlags::enableInteractiveInlineButtons(); +} + bool NativeReactNativeFeatureFlags::enableInteropViewManagerClassLookUpOptimizationIOS( jsi::Runtime& /*runtime*/) { return ReactNativeFeatureFlags::enableInteropViewManagerClassLookUpOptimizationIOS(); diff --git a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h index 57c6de644796..298ac996392f 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h +++ b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h @@ -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<<8a2f66b9c52af093e010ec566e85a8fc>> */ /** @@ -118,6 +118,8 @@ class NativeReactNativeFeatureFlags bool enableInteractableResponderViews(jsi::Runtime& runtime); + bool enableInteractiveInlineButtons(jsi::Runtime& runtime); + bool enableInteropViewManagerClassLookUpOptimizationIOS(jsi::Runtime& runtime); bool enableIntersectionObserverByDefault(jsi::Runtime& runtime); diff --git a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js index b3dc3625a994..84b6406e8019 100644 --- a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js +++ b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js @@ -482,6 +482,17 @@ const definitions: FeatureFlagDefinitions = { }, ossReleaseStage: 'none', }, + enableInteractiveInlineButtons: { + defaultValue: false, + metadata: { + dateAdded: '2026-10-30', + description: + 'When enabled, inline text with a button role produces a ClickableSpan (like a link).', + expectedReleaseValue: true, + purpose: 'experimentation', + }, + ossReleaseStage: 'none', + }, enableInteropViewManagerClassLookUpOptimizationIOS: { defaultValue: false, metadata: { diff --git a/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js index a18691559250..8700c830f2a2 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<<1d0ac515dbfd0d2b50a8a139e5eefce4>> * @flow strict * @noformat */ @@ -88,6 +88,7 @@ export type ReactNativeFeatureFlags = Readonly<{ enableImperativeEvents: Getter, enableImperativeFocus: Getter, enableInteractableResponderViews: Getter, + enableInteractiveInlineButtons: Getter, enableInteropViewManagerClassLookUpOptimizationIOS: Getter, enableIntersectionObserverByDefault: Getter, enableKeyEvents: Getter, @@ -382,6 +383,10 @@ export const enableImperativeFocus: Getter = createNativeFlagGetter('en * Android views that declare a gesture-responder handler (e.g. PanResponder) register a no-op touch listener so they can be recognized as interactable. */ export const enableInteractableResponderViews: Getter = createNativeFlagGetter('enableInteractableResponderViews', false); +/** + * When enabled, inline text with a button role produces a ClickableSpan (like a link). + */ +export const enableInteractiveInlineButtons: Getter = createNativeFlagGetter('enableInteractiveInlineButtons', false); /** * This is to fix the issue with interop view manager where component descriptor lookup is causing ViewManager to preload. */ diff --git a/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js index db021f9f0472..309f8e3053c5 100644 --- a/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +++ b/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.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<<54518bfc610a756175f0535d28d1e77d>> + * @generated SignedSource<<609fe8c13075c497da44e758a1de19d9>> * @flow strict * @noformat */ @@ -65,6 +65,7 @@ export interface Spec extends TurboModule { readonly enableImperativeEvents?: () => boolean; readonly enableImperativeFocus?: () => boolean; readonly enableInteractableResponderViews?: () => boolean; + readonly enableInteractiveInlineButtons?: () => boolean; readonly enableInteropViewManagerClassLookUpOptimizationIOS?: () => boolean; readonly enableIntersectionObserverByDefault?: () => boolean; readonly enableKeyEvents?: () => boolean;