Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix collisions in UITextView for onPress events #3017

Merged
merged 1 commit into from
Feb 28, 2024

Conversation

haileyok
Copy link
Contributor

Right now, we find the pressed string's indices in the NSAttributedString with fullText.range(of: childText). However, we are not taking into account situations where there may be duplicate strings as in the screenshot below. Each of these has a different onPress handler, and the press location will not be the same. However, we are not offsetting the search as we loop through each child.

Instead, we need to save the last offset and apply that to the search, like so:

let range = fullText.range(of: childText, options: [], range: startIndex..<fullText.endIndex)
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-02-28.at.08.28.52.mp4

@pfrazee pfrazee merged commit 5cb45f9 into main Feb 28, 2024
4 checks passed
@pfrazee pfrazee deleted the hailey/similar-link-uitext branch February 28, 2024 16:31
estrattonbailey pushed a commit that referenced this pull request Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants