From e9baa0578f9f763f4cc12255b2e7ba00debdc4b5 Mon Sep 17 00:00:00 2001 From: Spence Pope Date: Wed, 3 Jun 2026 10:58:43 -0400 Subject: [PATCH] Fix alt text selection in lightbox on Android (and iOS) (#10698) Co-authored-by: Eric Bailey (cherry picked from commit b6650d8d5c0a9dc2adbe53ce727e8a3901f0edd7) --- src/components/Lightbox/chrome/Footer.tsx | 47 ++++++++++++++--------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/src/components/Lightbox/chrome/Footer.tsx b/src/components/Lightbox/chrome/Footer.tsx index fb190f42ff..a20c80df3d 100644 --- a/src/components/Lightbox/chrome/Footer.tsx +++ b/src/components/Lightbox/chrome/Footer.tsx @@ -1,11 +1,5 @@ import {useRef} from 'react' -import { - LayoutAnimation, - Pressable, - ScrollView, - StyleSheet, - View, -} from 'react-native' +import {LayoutAnimation, ScrollView, StyleSheet, View} from 'react-native' import {useSafeAreaInsets} from 'react-native-safe-area-context' import {BlurView} from 'expo-blur' import {useLingui} from '@lingui/react/macro' @@ -60,26 +54,41 @@ export function Footer({altText, isAltExpanded, onToggleAltExpanded}: Props) { isMomentumScrolling.current = false }} contentContainerStyle={[a.px_md, a.py_sm]}> - { - if (isMomentumScrolling.current) return - LayoutAnimation.configureNext({ - duration: 450, - update: {type: 'spring', springDamping: 1}, - }) - onToggleAltExpanded() - }}> + accessibilityHint=""> + {/* + * The press handlers must live on the Text itself, not on a + * wrapping Pressable. Text selection is driven by the platform's + * native text view long-press (RN Text on Android, UITextView on + * iOS). A parent touchable consumes that long-press before the + * selectable Text can begin a selection - on Android this prevents + * selection entirely. Keeping onPress/onLongPress on the Text lets + * the same native node own both the tap-to-expand and the + * long-press-to-select. The empty onLongPress is intentional: it + * reserves the long-press for the OS selection gesture instead of + * firing the expand toggle. RN exposes no API to arbitrate tap vs + * native selection on a single node, so this is the supported + * workaround, and it behaves consistently on both platforms. + */} + numberOfLines={isAltExpanded ? undefined : 3} + onPress={() => { + if (isMomentumScrolling.current) return + LayoutAnimation.configureNext({ + duration: 450, + update: {type: 'spring', springDamping: 1}, + }) + onToggleAltExpanded() + }} + onLongPress={() => {}}> {altText} - +