72 Contextual Menu Position. 72 of 95.
72/FLOATING GEOMETRY/72 of 95
Contextual Menu Position
A right-click menu should open at your finger, then stay on screen.
The problem
A context menu that always opens the same way spills off the edge when you click near a corner.
The solution
The menu opens at the pointer and flips to stay inside the viewport.
Experiment
How it works
- The pointer position at right-click is the anchor, not a button rectangle.
- The menu is placed at that point first.
- Its box is measured against the viewport edges.
- If it would overflow, alignment flips to the side that has room.
- Any remaining overflow is clamped so the menu stays on screen.
Seen in
Right-click menus
Actions open at the cursor and never spill off screen.
Canvas tools
Context actions appear where you clicked in the workspace.
File managers
Item menus flip near edges to stay fully visible.
Data grids
Cell menus position at the pointer and adjust for bounds.