ContextMenu component wraps the Gantt component and intercepts right-click events to show a context menu. Connect it to the chart via the shared api prop so built-in actions work automatically.
Basic setup
Gantt must be a direct child (or descendant) of ContextMenu. The menu component listens to pointer events that bubble up from the chart.ContextMenu props
The Gantt API object. Connects the menu so built-in actions are dispatched to the chart.
Array of menu item descriptors. Overrides the default option set.
Callback fired when a menu item is clicked. Receives the right-clicked task context and the selected action descriptor.
Default menu options
ThedefaultMenuOptions array and the getMenuOptions() helper give you a copy of the built-in option configuration:
| ID | Description |
|---|---|
add-task | Sub-menu: add child, above, or below |
add-task:child | Add a child task |
add-task:before | Add a task above |
add-task:after | Add a task below |
convert-task | Sub-menu: convert to another task type |
edit-task | Open the editor for the task |
cut-task | Cut the task |
copy-task | Copy the task |
paste-task | Paste the clipboard task |
move-task:up | Move the task up |
move-task:down | Move the task down |
indent-task:add | Indent the task |
indent-task:remove | Outdent the task |
delete-task | Delete the task |
Customising the menu
CallgetMenuOptions() to start from the defaults, then select the options you want and append custom items:
Menu item config fields
Unique identifier for the item. When a built-in ID is used, the corresponding Gantt action is dispatched automatically on click.
Label displayed in the menu.
Icon class name shown next to the label.
Secondary text displayed to the right of the label (typically a keyboard shortcut).
Set to
"separator" to render a horizontal divider instead of a clickable item.Nested array of options for creating sub-menus.
Click handler for custom items. If provided, the handler is called instead of dispatching a Gantt action.
Function returning
true to disable the item for a particular task or state.Function returning
true to hide the item for a particular task or state.