Skip to content

feat: custom selection color#250

Merged
hryhoriiK97 merged 10 commits intosoftware-mansion-labs:mainfrom
xindixu:feat/custom-selection-color-pr
Apr 24, 2026
Merged

feat: custom selection color#250
hryhoriiK97 merged 10 commits intosoftware-mansion-labs:mainfrom
xindixu:feat/custom-selection-color-pr

Conversation

@xindixu
Copy link
Copy Markdown
Contributor

@xindixu xindixu commented Apr 18, 2026

What/Why?

Add support for custom selection color to the <EnrichedMarkdownText /> component. Added 2 props: selectionColor and selectionHandleColor. See React Native doc:
https://reactnative.dev/docs/textinput#selectioncolor and https://reactnative.dev/docs/textinput#selectioncolor for more detail

Testing

Test with selecting text in both ios and android.

Screenshots

iOS Android web
ios custom selection color android custom selection color web custom selection color

PR Checklist

  • Code compiles and runs on iOS
  • Code compiles and runs on Android
  • Updated documentation/README if applicable
  • Ran example app to verify changes

@hryhoriiK97 hryhoriiK97 self-requested a review April 18, 2026 11:09
Copy link
Copy Markdown
Collaborator

@hryhoriiK97 hryhoriiK97 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! It's a great addition to enriched-markdown 🙌 ❤️

Before going further on implementation details, I'd like to propose simplifying the API.

react-native-enriched solves the same problem with a single selectionColor prop, explicitly aligning with React Native's convention (TextInput also exposes only selectionColor — no selectionHandleColor).

We'd like to match that pattern here. I recommend checking their implementation for reference.

@xindixu
Copy link
Copy Markdown
Contributor Author

xindixu commented Apr 18, 2026

@hryhoriiK97 Thank you for the review! ❤️

(TextInput also exposes only selectionColor — no selectionHandleColor).

I'm pretty new to React Native, so I could be wrong. The React Native doc does mention the selectionHandleColor prop for Android: https://reactnative.dev/docs/textinput#selectionhandlecolor-android

In Android, the handler color matches the selection color precisely, but the selection color needs to be much lighter for the underlying text to be shown properly. iOS has the computation done automatically, but Android doesn't. Basically, I'm trying to make the experience look similar in iOS and Android.

Set selectionHandleColor to the same value as selectionColor
same color

Set selectionHandleColor to a darker value than selectionColor

different color

@hryhoriiK97
Copy link
Copy Markdown
Collaborator

@hryhoriiK97 Thank you for the review! ❤️

(TextInput also exposes only selectionColor — no selectionHandleColor).

I'm pretty new to React Native, so I could be wrong. The React Native doc does mention the selectionHandleColor prop for Android: https://reactnative.dev/docs/textinput#selectionhandlecolor-android

In Android, the handler color matches the selection color precisely, but the selection color needs to be much lighter for the underlying text to be shown properly. iOS has the computation done automatically, but Android doesn't. Basically, I'm trying to make the experience look similar in iOS and Android.

Set selectionHandleColor to the same value as selectionColor same color

Set selectionHandleColor to a darker value than selectionColor

different color

@xindixu thank you for catching this! I'd totally missed this prop. In that case, let's go with this:

  • selectionColor — iOS + Android + web.
  • selectionHandleColor — Android only (mark as @platform android in the JSDoc). Ignored on iOS entirely.
  • Web: drop the accent-color implementation. It doesn't tint selection handles and accidentally tints task list checkboxes. Only selectionColor should affect ::selection.

@xindixu
Copy link
Copy Markdown
Contributor Author

xindixu commented Apr 20, 2026

@hryhoriiK97 Updated based on your review! PTAL. Thanks!

@xindixu xindixu requested a review from hryhoriiK97 April 20, 2026 17:12
Copy link
Copy Markdown
Collaborator

@hryhoriiK97 hryhoriiK97 left a comment

Choose a reason for hiding this comment

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

@xindixu I’ve done an initial review and left a few comments 🙂

Comment thread android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownText.kt Outdated
Comment thread android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownManager.kt Outdated
Comment thread ios/EnrichedMarkdown.mm
Comment thread ios/EnrichedMarkdownText.mm
Comment thread src/web/EnrichedMarkdownText.tsx
Comment thread src/web/EnrichedMarkdownText.tsx Outdated
Comment thread src/EnrichedMarkdownNativeComponent.ts
Comment thread src/EnrichedMarkdownTextNativeComponent.ts
Comment thread src/types/MarkdownTextProps.ts
Comment thread src/types/MarkdownTextProps.web.ts
@xindixu xindixu force-pushed the feat/custom-selection-color-pr branch from 2fb32c5 to 90edd78 Compare April 21, 2026 18:36
@xindixu
Copy link
Copy Markdown
Contributor Author

xindixu commented Apr 21, 2026

@hryhoriiK97 thank you for the detailed review! I've addressed all your feedback.

New tests:

iOS:

ios.selection.color.mov

Android:

android.selection.color.mov

@xindixu xindixu requested a review from hryhoriiK97 April 21, 2026 18:39
Copy link
Copy Markdown
Collaborator

@hryhoriiK97 hryhoriiK97 left a comment

Choose a reason for hiding this comment

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

Thank you for addressing all the comments! A few additional ones from me 🙏

Comment thread src/web/EnrichedMarkdownText.tsx Outdated
Comment thread ios/input/EnrichedMarkdownTextInput.mm Outdated
Comment thread ios/EnrichedMarkdown.mm Outdated
Comment thread ios/EnrichedMarkdownText.mm Outdated
@xindixu xindixu force-pushed the feat/custom-selection-color-pr branch from 4628d7b to 6972ae2 Compare April 22, 2026 19:39
@xindixu xindixu requested a review from hryhoriiK97 April 22, 2026 19:42
@xindixu
Copy link
Copy Markdown
Contributor Author

xindixu commented Apr 22, 2026

@hryhoriiK97 Addressed all your feedback. PTAL!

Built android app again and verified that it works as expected

Screenshot 2026-04-22 at 12 43 41 PM

Copy link
Copy Markdown
Collaborator

@hryhoriiK97 hryhoriiK97 left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! 🚀 A few things still worth improving 0 I'll handle those in follow-up PRs to keep this PR's scope focused. selectionColor will be available in tomorrow's nightly release.

@hryhoriiK97 hryhoriiK97 merged commit 25706b1 into software-mansion-labs:main Apr 24, 2026
5 checks passed
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.

3 participants