Skip to content

Deprecate scopeType in ContextMenuItem API #8838

@maribethb

Description

@maribethb

Check for duplicates

  • I have searched for similar issues before opening a new one.

Problem

Context menus can currently only be opened on blocks, workspaces, and workspace comments. It must be possible to open them on any focusable item that wants to show them, such as connections.

We'll deprecate the scopeType property. Instead, context menu items will be responsible for setting their own scopes through the preconditionFn. For example, the "Delete Block" menu item should only appear if the focused item is a block. The precondition for this menu item will return 'hidden' if the scope.focusedNode is not a Block.

Request

  1. Make the scopeType property in the ContextMenuItem type optional.
  2. Add backwards-compatibility for existing context menu items:
    • At registration time, if a menu item is registered that passes in a scopeType property, wrap the supplied preconditionFn in a function that returns hidden if the scope does not match the scopeType.
    • Add tests to make sure backwards-compatibility is intact.
  3. Update the existing context menu items to have appropriate preconditionFns.
  4. Remove the checks based on scopeType from the getContextMenuOptions function in the registry. All registered items will have their preconditions checked.

Alternatives considered

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

issue: feature requestDescribes a new feature and why it should be added

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions