Repository navigation
fix(menu): position the context menu with gpui-base Positioner - #566
Merged
Merged
Conversation
Positioner::corner clamps into the viewport the way base's own Popup does, including the frame insets of a client-decorated window, which anchored().snap_to_window_with_margin did not.
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.
Changed behaviour
ContextMenuplaced its menu with GPUI's rawanchored().snap_to_window_with_margin(px(8.)). It now usesgpui_base::Positioner::corner, the same corner-anchoring base's ownPopupuses, so a context menu is clamped into the viewport the same way every other popup is — including the frame insets of a client-decorated window, whichanchoredignored — and occludes what it covers like base popups do. The 8px margin matches basePopup's window margin, which base keeps private; the comment says so.Per Principle 7 as extended in #564.
Tests
New
context_menu_opens_at_the_pointer_and_stays_in_the_window: the contract from #285 (menu top-left at the right-click point; clamped to the window margin near an edge) now has a test, so the primitive swap and future ones are checked against it. Existinglong_press_dismissal_consumes_outside_tapand the Markdown link context-menu tests still pass.Checks run
cargo fmt --all --check,cargo clippy --workspace --all-targets --locked -- -D warningscargo nextest run -p tcode-ui --locked— all passedNot verified visually (no Accessibility/Screen Recording permission for the computer-use tools on this machine); placement is asserted by the new test.