fix: align code selection menu with selection across editors#866
Open
ML-dev-crypto wants to merge 2 commits intoaccordproject:mainfrom
Open
fix: align code selection menu with selection across editors#866ML-dev-crypto wants to merge 2 commits intoaccordproject:mainfrom
ML-dev-crypto wants to merge 2 commits intoaccordproject:mainfrom
Conversation
- Replace hardcoded x=225 with position.x so menu follows selection horizontally - Convert editor-relative coordinates to viewport coordinates by adding editorRect.left/top - Use getEndPosition for Y so menu appears above last line of multi-line selections - Use getStartPosition for X so menu anchors to selection start, not end cursor Signed-off-by: ML-dev-crypto <ml.dev.crypto@example.com>
✅ Deploy Preview for ap-template-playground ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes the CodeSelectionMenu placement so it follows the actual text selection position (X/Y) across Monaco-based editors, addressing misalignment that was especially visible in the JSON editor.
Changes:
- Use
position.xfor the menu’s horizontal placement instead of a fixed X value. - Update
useCodeSelectionto compute menu coordinates using editor selection start/end visible positions and editor container offsets. - Improve multi-line selection handling by mixing start (X) and end (Y) selection coordinates.
When .editorwrapper container is not found, the fallback branch was using editor-local coordinates directly as viewport coordinates, causing the menu to appear near the page origin. Fix: use editor.getDomNode().getBoundingClientRect() to get the editor's viewport offset and add it to startPosition.left and endPosition.top before clamping. Return early if getDomNode() returns null. Signed-off-by: Ansh Rai <anshrai331@gmail.com>
3b4a6a7 to
c77844c
Compare
Contributor
Author
|
Hi! @DianaLease any feedback |
Contributor
Author
|
Hi! @mttrbrts any feedback..???? |
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.
Closes #865
Problem
The code selection menu was not correctly aligned with selected text, especially in the JSON editor. The horizontal position was constrained and did not reflect the actual selection position.
Changes
position.xgetBoundingClientRect()to convert editor-local coords to viewport coords in the fallback branchgetDomNode()returns nullTesting
Author Checklist
--signoff)mainfromML-dev-crypto:fix/code-selection-menu-position