Capítulo 20 de 51
A right-click (long-press on touch) triggered menu sharing the full Menu part vocabulary (items, submenus, radio/checkbox items) — must always be an enhancement, never the only way to reach an action, since context menus are hard to discover on touch devices and with assistive technology.
Root → Trigger, Portal → Backdrop, Positioner → Popup (Arrow, Item, LinkItem, Separator, SubmenuRoot → SubmenuTrigger, Group → GroupLabel, RadioGroup → RadioItem → RadioItemIndicator, CheckboxItem → CheckboxItemIndicator) — identical item vocabulary to Menu (ch027), positioned at the pointer instead of anchored to a trigger element.Positioner still exposes the standard side/align/collisionBoundary/sticky family, but positions relative to the pointer/long-press location rather than the Trigger element.SubmenuRoot/SubmenuTrigger for nested submenus, openOnHover/delay/closeDelay on SubmenuTrigger control hover-opening behavior — same pattern as Menu.closeParentOnEsc: on Root/SubmenuRoot, controls whether Esc in a submenu also closes the parent context menu.| Part | Notable props | Notable data attributes |
|---|---|---|
Root | open/onOpenChange, closeParentOnEsc, loopFocus, highlightItemOnHover | — |
Item | label, onClick, closeOnClick, disabled | data-highlighted, data-disabled |
CheckboxItem | checked/onCheckedChange, closeOnClick | data-checked, data-unchecked, data-highlighted |
RadioGroup/RadioItem | value/onValueChange (group), value (item) | data-checked, data-unchecked |
SubmenuTrigger | openOnHover, delay, closeDelay | data-popup-open, data-highlighted |
LinkItem | label, closeOnClick | data-highlighted |
ContextMenu.Item with an equivalent visible button, toolbar action, or menu entry elsewhere.Root differ.closeParentOnEsc deliberately: default nested-Esc behavior may not match a deeply nested submenu UX — test the multi-level Esc path explicitly.eventDetails cancel/reason pattern applies to onOpenChange here too.