Repository navigation
Support dataDetectorType on iOS Text - #59738
Open
hryhoriiK97 wants to merge 1 commit into
Open
hryhoriiK97 wants to merge 1 commit into
hryhoriiK97 wants to merge 1 commit into
Conversation
|
Warning JavaScript API change detected This PR commits an update to
This change was flagged as: |
`dataDetectorType` only existed on Android. On iOS the prop was ignored, so apps had to find links in the text themselves and split it into nested Text. The prop lives in the iOS paragraph props, the same way Android keeps its own in its platform folder. Android code doesn't change. Detection runs when the text is drawn and hit tested, not when it is measured, because the attributes it adds don't change the layout. A tap on detected data opens its URL, and VoiceOver gets an element for each link. Only http, https, mailto and tel URLs open. NSDataDetector also matches other schemes, which must not turn text in the app into deep links. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hryhoriiK97
force-pushed
the
ios-text-data-detector
branch
from
November 1, 2026 21:01
aa0866d to
20b4b61
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
dataDetectorTypeonTextonly works on Android. On iOS the prop is ignored, so an app that wants tappable phone numbers, links or emails has to find them itself and split the text into nestedTextcomponents.This adds the prop on iOS, with the same values as Android:
phoneNumber,link,email,noneandall. Detected data gets the link color and an underline, a tap opens it, and VoiceOver gets a link element for it.text/platform/cxx, which is what iOS compiles. Android keeps its own intext/platform/android, so no Android code changes.http,https,mailtoandtelURLs open, so text from a user can't open a deep link into another app.Changelog:
[IOS] [ADDED] - Support
dataDetectorTypeonTextTest Plan:
New example in RNTester: Text > Data detectors.
datadetector-1-types.mp4
datadetector-2-cases.mp4
dataDetectorTypeon the same text. A tap on a link opens Safari, and plain text andnonedo nothing.onPress, long press, scrolling from a link, and links in padded, emoji and RTL text.Unit tests, 5 new in
RCTTextDataDetectorTests:To run these I removed
RCTImageLoaderTests.mfrom the target locally, because it doesn't compile onmain: it usesRCTDefineImageURLLoader, which no longer exists.Fantom, 6 new tests in
Text-itest.js, plus every suite that prints aText: 528 passed, 4 skipped.On the iPhone 18 Pro simulator (iOS 27):
nonestays plain.tel:5551234567andmailto:hello@example.com, because the simulator has no app for them.myapp://andfile://stay plain.onPresson the plain part of the text still fires, a long press onselectabletext only shows Copy, and a scroll that starts on a link doesn't open it.Cost, on an iPhone 15 Pro with a Release build: in a 600-row
FlatListof 7–200 character messages where every row sets the prop, the median draw time per row goes from 484 µs to 1,627 µs (3 runs per arm), so about 1.1 ms per newly drawn row.Textwithout the prop only pays for one comparison.yarn flow-check, ESLint, Prettier and clang-format are clean, andyarn build-types,yarn test-generated-typescriptand the C++ API snapshots are up to date.Not run: VoiceOver itself (I read the accessibility tree), a physical device and tvOS.
🤖 Generated with Claude Code