react-native-selectable-text icon indicating copy to clipboard operation
react-native-selectable-text copied to clipboard

onPress event for child nodes seem to get blocked on iOS

Open jonasfrid opened this issue 6 years ago • 2 comments

Hi there! This is a great library, although I'm having some trouble with nested, styled <Text> components inside a SelectableText.

I'm doing the following:

 <SelectableText
        value={textElements}
        style={style}
        menuItems={[
         'foo',
         'bar'
        ]}
        onSelection={this.pressedSelection}
      />

where textElements is an array of <Text onPress={myOnPressFn} style={{myStyle}}> elements with custom styles and highlights. However, myOnPressFn does not get called on iOS, only on Android. Why might this be?

Kind regards, Jonas

jonasfrid avatar Feb 06 '20 20:02 jonasfrid

Hello, We are facing this same issue. onPress doesn't do anything on iOS, does anyone have a solution for this issue?

kimhung2 avatar Apr 13 '20 23:04 kimhung2

As @sbatson5 pointed out in the duplicate of this issue (#55), this seems to be a limitation because SelectableText on iOS is using TextInput (if I'm understanding this line correctly although I readily admit my Objective C is not strong) The Android native view however is inheriting from TextView and seems to pass onPress events correctly to its children

Is there a reason the iOS native view is built on top of TextInput instead of TextView?

nsantacruz avatar Jan 18 '21 09:01 nsantacruz