Skip to content

Support dataDetectorType on iOS Text - #59738

Open
hryhoriiK97 wants to merge 1 commit into
react:mainfrom
hryhoriiK97:ios-text-data-detector
Open

hryhoriiK97 wants to merge 1 commit into
react:mainfrom
hryhoriiK97:ios-text-data-detector

Conversation

@hryhoriiK97

@hryhoriiK97 hryhoriiK97 commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

dataDetectorType on Text only 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 nested Text components.

This adds the prop on iOS, with the same values as Android: phoneNumber, link, email, none and all. Detected data gets the link color and an underline, a tap opens it, and VoiceOver gets a link element for it.

  • The prop lives in the paragraph props in text/platform/cxx, which is what iOS compiles. Android keeps its own in text/platform/android, so no Android code changes.
  • Detection runs when the text is drawn, hit tested or read by accessibility. It never runs for measuring, because the added attributes don't change the layout. Text without the prop only pays for one comparison.
  • Only http, https, mailto and tel URLs open, so text from a user can't open a deep link into another app.

Changelog:

[IOS] [ADDED] - Support dataDetectorType on Text

Test Plan:

New example in RNTester: Text > Data detectors.

Data types Harder cases
datadetector-1-types.mp4
datadetector-2-cases.mp4
Each dataDetectorType on the same text. A tap on a link opens Safari, and plain text and none do nothing. Toggling the prop, custom schemes staying plain, onPress, long press, scrolling from a link, and links in padded, emoji and RTL text.

Unit tests, 5 new in RCTTextDataDetectorTests:

xcodebuild test -workspace RNTesterPods.xcworkspace -scheme RNTester \
  -destination "platform=iOS Simulator,id=<iPhone 18 Pro, iOS 27>" \
  -only-testing:RNTesterUnitTests/RCTTextDataDetectorTests
Executed 5 tests, with 0 failures (0 unexpected)

To run these I removed RCTImageLoaderTests.m from the target locally, because it doesn't compile on main: it uses RCTDefineImageURLLoader, which no longer exists.

Fantom, 6 new tests in Text-itest.js, plus every suite that prints a Text: 528 passed, 4 skipped.

On the iPhone 18 Pro simulator (iOS 27):

  • Each type styles only its own data, and none stays plain.
  • A tap on a link opens Safari. Phone numbers and emails reach the system as tel:5551234567 and mailto:hello@example.com, because the simulator has no app for them.
  • Plain text does nothing on tap, and myapp:// and file:// stay plain.
  • onPress on the plain part of the text still fires, a long press on selectable text only shows Copy, and a scroll that starts on a link doesn't open it.
  • Links work with padding, nested styles, emoji and RTL text, and toggling the prop updates the styling and link elements.

Cost, on an iPhone 15 Pro with a Release build: in a 600-row FlatList of 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. Text without the prop only pays for one comparison.

yarn flow-check, ESLint, Prettier and clang-format are clean, and yarn build-types, yarn test-generated-typescript and 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

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 1, 2026
@facebook-github-tools facebook-github-tools Bot added p: Software Mansion Partner: Software Mansion Partner labels Nov 1, 2026
@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

Warning

JavaScript API change detected

This PR commits an update to ReactNativeApi.d.ts, indicating a change to React Native's public JavaScript API.

  • Please include a clear changelog message.
  • This change will be subject to additional review.

This change was flagged as: POTENTIALLY_BREAKING

@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Nov 1, 2026
`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
hryhoriiK97 force-pushed the ios-text-data-detector branch from aa0866d to 20b4b61 Compare November 1, 2026 21:01

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Software Mansion Partner: Software Mansion Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant