fix(android): block mention events when cursor is inside a finalized mention span#489
Conversation
…mention span Mirror iOS conflicting-styles behaviour in afterTextChangedMentions: - After determining the candidate range [finalStart, finalEnd], scan for EnrichedInputMentionSpan across the full range (not just currentWord). - If the span text matches the buffer, the mention is intact — call endMention() to suppress the event (fixes spurious mention list pop-up when a pre-filled @mention is loaded, e.g. in reply flows). - If the span text has diverged (user edited inside it), remove the stale span and record mentionStart = spanStart so setMentionSpan can later replace the correct range when the user picks a new mention.
|
Hi @Jianlong-Nie, |
If you take a closer look, it does trigger — in the video, it fires when deleting the fourth or fifth character. I’ve added some throttling here, so it’s not triggered immediately on every single change. @kacperzolkiewski |
|
@Jianlong-Nie Thank you for your contribution! |
|
Linking the issue as requested: fixes #490 |
Problem
On Android, after a mention is finalized (user selects from the suggestion list), typing new characters after the mention continues to trigger the mention suggestion list.
Root cause:
afterTextChangedMentionsuses apreviousWordfallback — when the cursor moves to a new word after the mention, it looks back and finds@usernameas the previous word, which matchesmentionRegex, causingonMentionto fire again even though the mention span is already resolved.Fix
After determining the candidate range
[finalStart, finalEnd], scan forEnrichedInputMentionSpanacross the full range:endMention()and return. This blocks the spurious event when the cursor is in a word adjacent to a finalized mention span (mirrors iOSconflictingStylesbehaviour).mentionStart = spanStartsosetMentionSpancan replace the correct range when the user picks a new mention.Changes
android/…/styles/ParametrizedStyles.kt— reworkedafterTextChangedMentionsspan-check logic.before:
MicrosoftTeams-video.-.2026-03-17T140027.449.1.mp4
after:
e9dd6268b745fccdc913bbf0dc4ed570.mp4