fix: align code selection menu with selection across editors#866
fix: align code selection menu with selection across editors#866ML-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. |
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
|
Hi! @DianaLease any feedback |
|
Hi! @mttrbrts any feedback..???? |
|
Thanks @ML-dev-crypto! This is a clean fix for the code selection menu positioning. Review Notes
One small suggestion: the magic number Ready for approval. This comment was generated by AI on behalf of @mttrbrts. |
|
Thanks for working on this @ML-dev-crypto, but after testing I'm going to close this PR. Issues Found
For Future PRsFor UI/UX fixes like this, please include:
This helps reviewers verify the fix works as intended before spending time on code review. Feel free to open a new PR if you'd like to take another approach that addresses these issues. This comment was generated by AI on behalf of @mttrbrts. |
|
Thanks for the detailed feedback @mttrbrts this is really helpful. |
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