DevactionUI.ContextMenu (devaction_ui v0.2.3)

Copy Markdown View Source

A menu of actions that opens on a right click, or on Shift + F10 (or the menu key) while the focus is in the area it belongs to, at the pointer and not under a button (DevactionUI.ContextMenu hook). The area is the area slot, such as the row of a list; the menu is the same as the one DevactionUI.Dropdown draws (icons, a shortcut at the right of an item, separators, a danger item) and it takes the same item slots, so the items are written once: with a more slot (the "···" icon) and a more_label the target also gets a button at its right that opens those same items as a dropdown, for whoever has no right button.

The menu is placed at the pointer, or at the focused element for the keyboard, and kept inside the window: it opens to the left or upwards of the point when it would not fit. ↑ ↓ Home End move round the items, the first letters of a name jump to an item, Enter or Space chooses, Esc closes it and gives the focus back to where it was, and so do Tab, a click outside, a scroll and a resize. The target carries data-open while its menu is open. The menu is position: fixed, so keep the component out of an ancestor with a transform, which would turn that point into its own corner.

An item is an action: it sends event with value as choice and values as phx-value-* to target, or goes to navigate, patch or href; disabled leaves it out of the keys. A separator puts a rule above the item and a heading a small caption.

Summary

Functions