From d906fe4fcfa4a919dbb66f4ec3f17e8f8be8bf02 Mon Sep 17 00:00:00 2001 From: Hailey Date: Tue, 16 Jan 2024 18:42:22 -0800 Subject: [PATCH] handle onpress better --- modules/expo-selectable-text/ios/ExpoUITextView.swift | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/expo-selectable-text/ios/ExpoUITextView.swift b/modules/expo-selectable-text/ios/ExpoUITextView.swift index 06a301a6ad..a428985c43 100644 --- a/modules/expo-selectable-text/ios/ExpoUITextView.swift +++ b/modules/expo-selectable-text/ios/ExpoUITextView.swift @@ -137,14 +137,17 @@ class ExpoUITextView: ExpoView { let text = textView.attributedText.string - return textChildren.first(where: { child in + for child in self.textChildren { let range = text.range(of: child.text ?? "") if let lowerBound = range?.lowerBound, let upperBound = range?.upperBound { - return charIndex >= lowerBound.utf16Offset(in: text) && charIndex <= upperBound.utf16Offset(in: text) + if charIndex >= lowerBound.utf16Offset(in: text) && charIndex <= upperBound.utf16Offset(in: text) { + return child + } } - return false - }) + } + + return nil } // Get the children. Always use getTextChildren() so that we ensure the correct order of views