Skip to content

fix: split manual links when newline inserted in link#624

Open
kacperzolkiewski wants to merge 9 commits into
mainfrom
@kacperzolkiewski/fix-onlink-detected
Open

fix: split manual links when newline inserted in link#624
kacperzolkiewski wants to merge 9 commits into
mainfrom
@kacperzolkiewski/fix-onlink-detected

Conversation

@kacperzolkiewski

@kacperzolkiewski kacperzolkiewski commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes: #556

Test Plan

Run reproduction steps from issue: #556
Issue should be resolved

Screenshots / Videos

Screen.Recording.2026-06-02.at.12.24.28.mov

Compatibility

OS Implemented
iOS
Android

Checklist

  • E2E tests are passing
  • Required E2E tests have been added (if applicable)

@kacperzolkiewski kacperzolkiewski marked this pull request as ready for review June 2, 2026 10:26
@kacperzolkiewski kacperzolkiewski requested review from exploIF and szydlovsky and removed request for szydlovsky June 2, 2026 10:26
@kacperzolkiewski kacperzolkiewski changed the title fix(android): split manual links when newline inserted in link fix: split manual links when newline inserted in link Jun 2, 2026
Comment thread ios/EnrichedTextInputView.mm Outdated

@szydlovsky szydlovsky left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iOS works fine

…ftware-mansion/react-native-enriched into @kacperzolkiewski/fix-onlink-detected

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses incorrect onLinkDetected behavior when a manually-inserted link is split across multiple lines by inserting newlines, ensuring link spans/events reflect the split segments correctly on both iOS and Android.

Changes:

  • iOS: refreshes manual link metadata so LinkData.text matches the current text in the refreshed range.
  • Android: splits manual link spans when newline characters are inserted inside a manual link, and de-duplicates onLinkDetected using (text, url, start, end) rather than just (text, url).
  • Example app: initializes selection state with a non-undefined default.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
ios/styles/LinkStyle.mm Updates refreshed manual link metadata to use the current substring for LinkData.text.
ios/EnrichedTextInputView.mm Avoids redundant/early active-style updates during text changes to prevent stale link detection.
apps/example/src/hooks/useEditorState.ts Provides a default {start,end,text} selection value instead of undefined.
android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedSelection.kt Improves link-detected event de-duping by including visible start/end offsets.
android/src/main/java/com/swmansion/enriched/textinput/styles/ParametrizedStyles.kt Splits manual link spans on newline insertion and factors span-application into a helper.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ios/EnrichedTextInputView.mm
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.

onLinkDetected invalid behavior when splitting a link over multiple lines

3 participants