Right-clicking a line in the dialogue editor put the markup menu off to one side
of the panel and stretched the panel as it overflowed, which is not what a
context menu should do.
The menu was rendered inline with position: fixed. The edit dialog's content
carries a transform for its open animation, and a transformed ancestor becomes
the containing block for fixed positioning, so the pointer's viewport coordinates
landed at those coordinates inside the dialog. It is portalled to the body now,
which detaches it from that ancestor, and still positioned at the pointer.
Three things had to follow from the portal:
- The admin stacks its dialog at 1300 and its own overlays up to 9999, so the
menu is placed at 10000 rather than underneath the panel.
- Payload styles every button with a light surface, which painted pale blocks
over the dark menu; item buttons are explicitly transparent now.
- A Radix modal sets pointer-events: none on the body while open, and a body
portal inherits it, leaving the menu visible but unclickable. It carries
pointer-events-auto.
Placement is a pure clampMenuPosition: the point is pulled inside the viewport so
a right-click near an edge cannot open a menu the author cannot reach. The menu
also closes on resize and on any scroll, so it never detaches from the box.
Verified in the running editor: the menu's rect starts exactly at the click point
(750, 308), its parent is the body, pointer-events is auto, the dialog reports no
overflow, and clicking the first item wrapped the caret with **. 4 unit tests
cover the clamp; 227 npc-dialogue tests pass.