fix: split manual links when newline inserted in link#624
fix: split manual links when newline inserted in link#624kacperzolkiewski wants to merge 9 commits into
Conversation
…ftware-mansion/react-native-enriched into @kacperzolkiewski/fix-onlink-detected
There was a problem hiding this comment.
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.textmatches the current text in the refreshed range. - Android: splits manual link spans when newline characters are inserted inside a manual link, and de-duplicates
onLinkDetectedusing(text, url, start, end)rather than just(text, url). - Example app: initializes
selectionstate 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.
| _recentInputString = [textView.textStorage.string copy]; | ||
|
|
||
| // emit onChangeText event | ||
| auto emitter = [self getEventEmitter]; | ||
| if (emitter != nullptr && _emitTextChange) { | ||
| // set the recent input string only if the emitter is defined | ||
| _recentInputString = [textView.textStorage.string copy]; | ||
|
|
There was a problem hiding this comment.
We can't have that here. It will bring back an issue from #270.
There is however a thing we could do to probably satisfy both needs:
set _recentInputString if emitter is defined, but not checking the _emitTextChange here - it should only be used for the actual emitting a bit later in the code.
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
Checklist