fix(Mention): Fix overlay positioned incorrectly with multi-line text that have text wrapping#249
Open
deepan wants to merge 1 commit intosadmann7:mainfrom
Open
fix(Mention): Fix overlay positioned incorrectly with multi-line text that have text wrapping#249deepan wants to merge 1 commit intosadmann7:mainfrom
deepan wants to merge 1 commit intosadmann7:mainfrom
Conversation
… that have text wrapping
Contributor
|
@deepan is attempting to deploy a commit to the sadmann7 Team on Vercel. A member of the Team first needs to authorize it. |
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.
Fixes: #248
The current
calculatePositionimplementation does not account for line wrapping in lines before the last line, which causes an incorrect vertical (Y-axis) offset.While we could extend
calculatePositionto handle wrapping for all lines, this approach would still be error prone. Our calculations rely on estimating line breaks by dividing character width by the text area width, which can differ from the browser’s actual text-wrapping behaviour.To avoid this mismatch, this PR introduces a more reliable approach using a mirror div. The mirror contains three span elements: the text before the trigger character, the trigger character itself, and the text after it. By measuring the trigger character’s offset relative to the text area, we can determine the overlay position accurately, independent of line wrapping.
Attaching a video of the fixed version for reference
Screen.Recording.2026-01-08.at.8.43.29.PM.mov