Skip to content

Custom context-menu commands - #3284

Draft
texodus wants to merge 1 commit into
masterfrom
context-menu-commands
Draft

texodus wants to merge 1 commit into
masterfrom
context-menu-commands

Conversation

@texodus

@texodus texodus commented Nov 9, 2026

Copy link
Copy Markdown
Member

This PR adds setCommandSchema(), an API which lets an app embedding <perspective-viewer> add its own commands to the right-click menu, with click context.

viewer.setCommandSchema((context) => {
      const id = context.hit?.row.security_id;
      return {
            commands: id == null ? [] : [{
                  kind: "Command",
                  key: "open-ticket",
                  label: `Open Ticket (${id})`,
            }],
      };
});

viewer.addEventListener("perspective-command", (event) => {
      const { key, context } = event.detail;
      if (key === "open-ticket") {
            openOrderTicket(context.hit.row.security_id, context.point);
      }
});
  • setCommandSchema() takes a synchronous function from a context (panel, table, plugin, view config, click point, and the hit under the cursor) to a list of Command / Group entries, shaped like plugin_config_schema.
  • Picking a command fires perspective-command with its key and the same context.
  • Plugins gain three optional methods: hit_test(x, y), plus command_schema() / execute_command() to offer commands of their own. Datagrid and charts implement hit_test.
  • React: commandSchema and onCommand props.
  • With no schema set, the right-click path is unchanged.

Signed-off-by: Andrew Stein <steinlink@gmail.com>
@texodus texodus added the enhancement Feature requests or improvements label Nov 9, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Feature requests or improvements

Development

Successfully merging this pull request may close these issues.

1 participant