<ContextMenu> component provides a right-click context menu for the Gantt chart. Wrap <Gantt> as a child of <ContextMenu> — it intercepts right-click events on task bars and grid rows and shows the menu at the cursor position.
Import
Basic usage
Props
The Gantt API instance. Required to resolve tasks, read state, and dispatch actions from menu items.
Custom menu item definitions. When non-empty, replaces the default menu entirely. When empty, items are generated automatically from
getMenuOptions() based on the current Gantt state.Custom function that resolves which task a right-click event belongs to. Receives the raw
data-id attribute value and the original mouse event. Return the task object to use, return true to fall back to the default task lookup, or return a falsy value to suppress the menu.Function called for each menu item before the menu is shown. Return
false to hide the item for the given task.Callback fired whenever a menu item is clicked. Called after any built-in action handler runs.
Positioning mode passed to the underlying menu widget.
'point' places the menu at the cursor.Additional CSS class names applied to the menu container.
The content to wrap — typically the
<Gantt> component. Right-click events within this subtree trigger the menu.Helper functions
getMenuOptions(options?)
Returns the default menu item configuration array.
defaultMenuOptions
The static default menu options array. Useful as a reference for the available item IDs.
Default menu items
| ID | Description |
|---|---|
add-task:before | Add a task above |
add-task:after | Add a task below |
add-task:child | Add a child task |
cut-task | Cut the task |
copy-task | Copy the task |
paste-task | Paste task |
delete-task | Delete the task |
split-task | Split the task (PRO) |
Customizing menu items
Filtering and extending default options
Filtering by task type
Use thefilter prop to hide specific items for certain task types:
Handling menu clicks
Use theonClick prop to respond to any menu action, including custom items:
Custom task resolver
By default the menu resolves which task was right-clicked by reading adata-id attribute from the DOM. Use resolver to override this behaviour: