Fix: Mentions no longer auto-insert trailing space#84105
Fix: Mentions no longer auto-insert trailing space#84105Julesssss merged 5 commits intoExpensify:mainfrom
Conversation
|
@hoangzinh Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2758850ced
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
|
||
| updateComment(`${commentBeforeAtSign}${mentionCode}${dotToAppend}${trimLeadingSpace(commentAfterMention)}`, true); | ||
| const selectionPosition = suggestionValues.atSignIndex + mentionCode.length + CONST.SPACE_LENGTH; | ||
| updateComment(`${commentBeforeAtSign}${mentionCode}${dotToAppend} ${trimLeadingSpace(commentAfterMention)}`, true); |
There was a problem hiding this comment.
Skip forced space when mention is followed by punctuation
insertSelectedMention now always concatenates ${dotToAppend} ${trimLeadingSpace(commentAfterMention)}, which inserts a space even when the existing text immediately after the replaced mention starts with punctuation (for example, editing "@a, thanks" with the cursor after @a now becomes "@adam@example.com , thanks"). This is a regression from the prior behavior that preserved adjacent punctuation and changes user-authored message formatting in mid-text edits.
Useful? React with 👍 / 👎.
| }); | ||
|
|
||
| it('preserves trailing punctuation dot when selected mention does not include dotted prefix', async () => { | ||
| it('preserves trailing punctuation dot and inserts trailing space when selected mention does not include dotted prefix', async () => { |
There was a problem hiding this comment.
can you add test cases with punctuation?
There was a problem hiding this comment.
Added the test case for punctuation
src/CONST/index.ts
Outdated
| SPECIAL_CHAR: /[,/?"{}[\]()&^%;`$=#<>!*]/g, | ||
| FIRST_SPACE: /.+?(?=\s)/, | ||
| TRAILING_DOTS: /\.$/, | ||
| STARTS_WITH_PUNCTUATION_WITHOUT_SPACE: /^[.,!?]/, |
There was a problem hiding this comment.
Why do we need the "WITHOUT_SPACE" suffix?
There was a problem hiding this comment.
Right, after re-reading the const name, I think it is redundant. I've updated the name
| updateComment(`${commentBeforeAtSign}${mentionCode}${dotToAppend}${trimLeadingSpace(commentAfterMention)}`, true); | ||
| const selectionPosition = suggestionValues.atSignIndex + mentionCode.length + CONST.SPACE_LENGTH; | ||
| const trimmedCommentAfterMention = trimLeadingSpace(commentAfterMention); | ||
| const spacer = !trimmedCommentAfterMention || !CONST.REGEX.STARTS_WITH_PUNCTUATION_WITHOUT_SPACE.test(trimmedCommentAfterMention) ? ' ' : ''; |
There was a problem hiding this comment.
Will spacer be true value when !trimmedCommentAfterMention is true? We need ensure space is a string object
There was a problem hiding this comment.
I'm not really sure about this concern, but the ternary operator would ensures spacer is always a string in this case
There was a problem hiding this comment.
ah I read it in a wrong way. Sorry
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppScreen.Recording.2026-03-09.at.16.55.16.movAndroid: mWeb ChromeScreen.Recording.2026-03-09.at.16.53.32.moviOS: HybridAppScreen.Recording.2026-03-09.at.17.14.14.moviOS: mWeb SafariScreen.Recording.2026-03-09.at.16.57.14.movMacOS: Chrome / SafariScreen.Recording.2026-03-09.at.16.51.13.mov |
|
@ryntgh I found a bug when insert mention with punctuation text
Actual result: "." is lost Screen.Recording.2026-03-06.at.14.31.49.mov |
|
@hoangzinh After investigating, seems like the issue exists in production as well. In Issue.mp4I think the |
|
🚧 @Julesssss has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/Julesssss in version: 9.3.36-0 🚀
|
|
🚀 Deployed to production by https://github.com/luacmartins in version: 9.3.36-10 🚀
|
Explanation of Change
This PR adds a trailing space after a mention so that the user can continue typing without breaking the mention. This PR also updates the cursor position calculation to account for the
dotToAppendcase, ensuring the cursor remains in the correct position when a mention ends with a dotFixed Issues
$ #83510
PROPOSAL: #83510 (comment)
Tests
Same as QA Steps
Offline tests
Same as QA Steps
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android-App-2.mp4
Android: mWeb Chrome
Android-mWeb-2.mp4
iOS: Native
iOS-App-2.mp4
iOS: mWeb Safari
iOS-mWeb-2.mp4
MacOS: Chrome / Safari
MacOS-Chrome.mp4