fix: incorrect cursor position after inserting mention - #41074
Conversation
Signed-off-by: Abhinav Kumar <abhinav@avitechlab.com>
|
Looks like this PR is ready to merge! 🎉 |
🦋 Changeset detectedLatest commit: c7acfb1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📜 Recent review details⏰ Context from checks skipped due to timeout. (4)
|
| Layer / File(s) | Summary |
|---|---|
replaceText cursor placement apps/meteor/app/ui-message/client/messageBox/createComposerAPI.ts |
replaceText now sets both selection endpoints to the computed insertion cursor after replacement. |
Regression coverage and release note apps/meteor/app/ui-message/client/messageBox/createComposerAPI.spec.ts, .changeset/moody-eggs-juggle.md |
The new spec covers mention insertion at the start, middle, and end of a message, and the changeset records the patch release note. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Suggested labels: type: bug
Suggested reviewers: MartinSchoeler
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title clearly summarizes the main fix: correcting cursor position after inserting a mention. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
Warning
Review ran into problems
🔥 Problems
Errors were encountered while retrieving linked issues.
Errors (1)
- CORE-2266: Request failed with status code 401
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #41074 +/- ##
===========================================
- Coverage 70.09% 69.48% -0.62%
===========================================
Files 3363 3663 +300
Lines 129711 145482 +15771
Branches 22494 26041 +3547
===========================================
+ Hits 90922 101086 +10164
- Misses 35476 40107 +4631
- Partials 3313 4289 +976
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Signed-off-by: Abhinav Kumar <abhinav@avitechlab.com>
Proposed changes (including videos or screenshots)
When inserting a user/channel mention while the caret is not at the end of the message, the cursor jumped to an incorrect position instead of landing right after the inserted mention, making continued typing and editing awkward.
The root cause was in
replaceTextincreateComposerAPI.ts: after replacing the partial trigger (e.g.@j) with the full mention, the new cursor position was computed from the textarea's live caret position before the replacement (selectionStart) rather than from where the text was actually inserted (selection.start). It also reset the caret back to the original position when a selection existed. This only appeared correct when mentioning at the end of the line, where the overshoot was clamped to the string length.The cursor is now placed at
selection.start + text.length, so it always lands immediately after the inserted mention regardless of where in the message it is inserted. Added unit tests forreplaceTextcovering insertion at the start, middle, and end of a message.Issue(s)
Steps to test or reproduce
@and select a user mentionFurther comments
CORE-2266
Summary by CodeRabbit