diff --git a/modules/react-native-ui-text-view/ios/RNUITextView.swift b/modules/react-native-ui-text-view/ios/RNUITextView.swift index 08aee88df0..9c21d45b5e 100644 --- a/modules/react-native-ui-text-view/ios/RNUITextView.swift +++ b/modules/react-native-ui-text-view/ios/RNUITextView.swift @@ -62,6 +62,7 @@ class RNUITextView: UIView { self.textView.frame.size = size self.textView.textContainer.maximumNumberOfLines = numberOfLines self.textView.attributedText = string + self.textView.selectedTextRange = nil if let onTextLayout = self.onTextLayout { var lines: [String] = [] @@ -107,16 +108,15 @@ class RNUITextView: UIView { fractionOfDistanceBetweenInsertionPoints: nil ) - for child in self.subviews { - guard let child = child as? RNUITextViewChild, let text = child.text else { - continue - } + for child in self.reactSubviews() { + if let child = child as? RNUITextViewChild, let childText = child.text { + let fullText = self.textView.attributedText.string + let range = fullText.range(of: childText) - let range = text.range(of: text) - - if let lowerBound = range?.lowerBound, let upperBound = range?.upperBound { - if charIndex >= lowerBound.utf16Offset(in: text) && charIndex <= upperBound.utf16Offset(in: text) { - return child + if let lowerBound = range?.lowerBound, let upperBound = range?.upperBound { + if charIndex >= lowerBound.utf16Offset(in: fullText) && charIndex <= upperBound.utf16Offset(in: fullText) { + return child + } } } } diff --git a/modules/react-native-ui-text-view/src/UITextView.tsx b/modules/react-native-ui-text-view/src/UITextView.tsx index 42dbcf6e1e..bbb45dccc6 100644 --- a/modules/react-native-ui-text-view/src/UITextView.tsx +++ b/modules/react-native-ui-text-view/src/UITextView.tsx @@ -33,7 +33,9 @@ export function UITextView({style, children, ...rest}: TextProps) { {...textDefaults} {...rest} ellipsizeMode={rest.ellipsizeMode ?? rest.lineBreakMode ?? 'tail'} - style={[{flex: 1}, flattenedStyle]}> + style={[{flex: 1}, flattenedStyle]} + onPress={undefined} // We want these to go to the children only + onLongPress={undefined}> {React.Children.toArray(children).map((c, index) => { if (React.isValidElement(c)) { return c