Skip to content

Commit 44901aa

Browse files
NickGerlemanmeta-codesync[bot]
authored andcommitted
Fix Double Fire of Pressable Text (#55606)
Summary: Pull Request resolved: #55606 D86657563, which enabled `link` role by default in JS for pressable text, exposed a bug in Facsimile, where we see hit testing, both against ClickableSpan, and normal React Tag based hit testing. We want the clickable spans for a11y/keyboarding, and can have non RN ClickableSpan that don't hit test via normal react mechanism. Don't remember how we tricked ReactTextView to not run into this. joevilches might. Changelog: [Internal] Reviewed By: cortinico Differential Revision: D93589114 fbshipit-source-id: ffb2c2bf2d5ffce10b7c805be550982efc277703
1 parent 93a765b commit 44901aa

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/PreparedLayoutTextView.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import com.facebook.react.uimanager.ReactCompoundView
2929
import com.facebook.react.uimanager.style.Overflow
3030
import com.facebook.react.views.text.internal.span.DrawCommandSpan
3131
import com.facebook.react.views.text.internal.span.ReactFragmentIndexSpan
32+
import com.facebook.react.views.text.internal.span.ReactLinkSpan
3233
import kotlin.collections.ArrayList
3334
import kotlin.math.roundToInt
3435

@@ -204,7 +205,12 @@ internal class PreparedLayoutTextView(context: Context) : ViewGroup(context), Re
204205

205206
if (action == MotionEvent.ACTION_UP) {
206207
clearSelection()
207-
clickableSpan.onClick(this)
208+
209+
// This will already get triggered by reactTagForTouch() based hit testing if it is React
210+
// managed clickable text. We still want to click any native ClickableSpan (e.g. for URIs).
211+
if (clickableSpan !is ReactLinkSpan) {
212+
clickableSpan.onClick(this)
213+
}
208214
} else if (action == MotionEvent.ACTION_DOWN) {
209215
val layout = checkNotNull(preparedLayout).layout
210216
val start = (layout.text as Spanned).getSpanStart(clickableSpan)

0 commit comments

Comments
 (0)