Repository navigation
fix(mentions): suppress mention autocomplete on email and domain patt… - #1406
Open
swarnendusahu10-dotcom wants to merge 1 commit into
Open
swarnendusahu10-dotcom wants to merge 1 commit into
swarnendusahu10-dotcom wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Description
Resolves #1287
Prevents the member mention autocomplete popup from firing and intercepting keystrokes when typing an email address or web domain (e.g.
contact admin @example.com,@gmail.com, or@company.io).Problem & Background
Whenever
@is typed after a space, EmbeddedChat enters mention-reading mode. If the user is typing an email address or domain, the popup appears and flickers against partial substring matches of room members.EnterKey Hijacking:Because the popup is active in the background, pressing
Enterto send the message intercepts the keypress. Instead of sending the email text, it auto-completes whichever random member happened to be highlighted (e.g. replacing@example.comwith@Alexandre), corrupting the user's message.A previous attempt in PR fix: resolve email mention trigger and paginate member list retrieval #1304 tried to unconditionally disable mentions whenever a dot (
.) was present. This was rejected because Rocket.Chat usernames explicitly support dots (e.g.@john.doe), which broke legitimate user mentions.Solution
.): Rather than maintaining a brittle, hardcoded list of 1,500+ top-level domains (.com,.org,.net,.io,.edu, etc.), any email or domain query universally contains a dot separator (.).@example.), the hook checks if any room member matches. If no member matches (!isValidUsername), it immediately closes the popup (setShowMembersList(false)), clearsfilteredMembers, and resetsmentionIndexto-1.EnterBehavior: By disarming the mention index, pressingEntercleanly sends the message with the email text intact instead of inserting an unwanted member.@john.doe),isValidUsernameevaluates totrue, so suggestions remain visible and selectable.Changes Made
packages/react/src/hooks/useSearchMentionUser.js: