fix: various mentions bugs and inconsistencies between platforms#637
Open
hejsztynx wants to merge 16 commits into
Open
fix: various mentions bugs and inconsistencies between platforms#637hejsztynx wants to merge 16 commits into
hejsztynx wants to merge 16 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses multiple cross-platform inconsistencies and edge-case bugs in “mentions” handling (trigger lifecycle events, selection-driven re-analysis, insertion behavior) across iOS, Android, and Web, and updates the example apps + E2E coverage to reflect the intended event semantics.
Changes:
- Web: refactors mention event handling into a React hook, fixes trigger range/query evaluation, and avoids inserting duplicate trailing spaces when setting a mention.
- iOS/Android: improves mention lifecycle event emission when switching directly between mentions, avoids duplicate events, and aligns “recent input” tracking to support selection-driven mention detection.
- E2E: adds Playwright coverage for switching between different mention triggers and validating end/start ordering.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/web/pmPlugins/MentionPlugin/useMentionEvents.ts | New React hook to subscribe to mention trigger + detected-mention events. |
| src/web/pmPlugins/MentionPlugin/subscribeMentionEvents.ts | Removes the prior imperative subscribe/unsubscribe helper. |
| src/web/pmPlugins/MentionPlugin/setMention.ts | Avoids inserting an extra trailing space when setting a mention. |
| src/web/pmPlugins/MentionPlugin/makeMentionPluginState.ts | Updates how the mention query range is computed (to word end) and adjusts indicator detection behavior. |
| src/web/pmPlugins/MentionPlugin/index.ts | Exports the new hook instead of the removed subscribe helper. |
| src/web/EnrichedTextInput.tsx | Switches mention event wiring from subscribeMentionEvents to useMentionEvents. |
| ios/styles/MentionStyle.mm | Fixes mention event emission ordering / deduping and avoids inserting duplicate spaces on mention insert. |
| ios/EnrichedTextInputView.mm | Ensures _recentInputString stays in sync even if no onChangeText emitter exists. |
| apps/example/src/hooks/useEditorState.ts | Updates example mention popup behavior to use start/end events rather than change events. |
| apps/example-web/src/testScreens/TestMentions.tsx | Extends the web test screen UI to expose last end-event indicator for assertions. |
| apps/example-web/src/App.tsx | Updates example popup-open behavior to align with start/end mention events. |
| android/src/main/java/com/swmansion/enriched/textinput/watchers/EnrichedTextWatcher.kt | Tracks recentInputString to support selection-only mention analysis. |
| android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedSelection.kt | Re-analyzes mentions on selection changes when text hasn’t changed. |
| android/src/main/java/com/swmansion/enriched/textinput/styles/ParametrizedStyles.kt | Adds selection-change mention detection path and renames internal detection helper. |
| android/src/main/java/com/swmansion/enriched/textinput/events/OnMentionEvent.kt | Disables event coalescing so end/start/change bursts aren’t collapsed. |
| android/src/main/java/com/swmansion/enriched/textinput/events/MentionHandler.kt | Ensures correct end→start→change sequence when switching mentions; improves dedupe logic. |
| android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputView.kt | Adds recentInputString storage on the view. |
| .playwright/tests/mentions.spec.ts | Adds E2E test for switching between different mentions and verifying lifecycle events. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
There were various bugs and inconsistencies with mentions functionalities across every platform.
Mainly it wasn't handled properly when you switched directly between different mentions, which caused improper event emission and the lists stayed visible - documented in the videos section
iOS:
onChangeevents when just moving a cursor across a mention_recentInputStringwas not updated if noonChangeTextprop was givenAndroid:
setMentiona duplicated space was inserted if there already was oneWeb:
setMentiona duplicated space was inserted if there already was oneExample apps:
onChangemention event would handle popup list opening - something whatonStartis forTest Plan
Follow the text written in the attached videos, play around with selection changes, all events should emit correctly and the lists should function as expected.
Screenshots / Videos
(all platforms) events not emitting when switching between mentions
Screen.Recording.2026-05-29.at.22.47.12.mov
(web) incorrect query evaluation and inserting, doubled space
Screen.Recording.2026-06-14.at.18.15.19.mov
Compatibility
Checklist