fix(super-editor): keep the context menu within the editor viewport and scroll area - #3839
fix(super-editor): keep the context menu within the editor viewport and scroll area#3839hitpopdimestop wants to merge 5 commits into
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
Code Review by Qodo
View medium (1)🟠 **Medium** 1.
|
The context menu opened at the raw click point with no clamping, so right-clicking near the right/bottom edge pushed it partly off-screen, and even a viewport clamp would render it under the scroll container scrollbar. Clamp the menu to the viewport intersected with the editor scroll container's content box (which excludes its scrollbar) after it renders.
036c523 to
a5a4016
Compare
There was a problem hiding this comment.
All reported issues were addressed across 4 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 4 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
Thanks again for the contribution! We revisited this PR and decided to merge it. I pushed a few updates to improve the fix and its test coverage, and I also opened a separate PR for v2. |
What & why
The right-click context menu opened at the raw click point with no clamping, so right-clicking near the right or bottom edge pushed it partly off-screen. Even a plain viewport clamp would leave it under the editor scroll container's scrollbar.
After the menu renders (so its size is known), it now clamps its position to the viewport intersected with the editor scroll container's content box —
clientWidth/clientHeightexclude that container's scrollbar, so the menu never lands under it. If the menu is larger than the available space on an axis, it renders as-is rather than trading one clipped edge for another.The positioning math lives in a small pure helper (
menu-position.js) so it's unit-testable independently of the Vue component.Screenshots
Before — the context menu is clipped at the right edge:

After — the context menu stays fully on-screen, clear of the scrollbar:

Test plan
menu-position.test.js: bounds clamp (right / bottom / left / top overflow), the scroll-container scrollbar case, the oversized "render as-is" case, andresolveMenuBounds(viewport-only + scroll-container intersection)..vueand test files;menu-position.jslints clean.)right = content-edge − 8px, clear of the 15px scrollbar.