AddThisFeature

Context Menu Primitive

Offer right-click actions as a shortcut to controls that are also visible elsewhere.

involved Components & Primitives

What it adds

A contextual menu bound to right-click and a keyboard equivalent, scoped to the item under the pointer.

What your agent is told to do

5
  1. 1

    Identify the surfaces where a contextual menu genuinely helps — table rows, file and item grids, canvas objects, tree nodes — and leave the rest of the app to the browser's own menu.

  2. 2

    Treat the context menu as an accelerator, never as the only route to an action. Every item in it must also be reachable from a visible control, because a right-click menu is undiscoverable and unavailable to many users.

  3. 3

    Bind a keyboard equivalent that opens the menu for the currently focused item and positions it against that item rather than against the last pointer coordinates.

  4. 4

    Build the menu's contents from the item actually targeted, and filter by the current user's permissions on that specific record before the menu opens.

  5. 5

    Item navigation, typeahead, disabled handling, submenus, and dismissal are owned by the Dropdown Menu Primitive; this feature owns only the trigger, the target resolution, and the positioning at a point. Do not fork a second menu implementation.

Edge cases it handles

7
  • There must be a keyboard route to the same menu — the context menu key and Shift-F10 on the focused item — otherwise the actions exist only for pointer users.
  • The browser's own menu is the right answer in places, and suppressing it universally is hostile. Leave it in text inputs, on selected text, on links, and on images, where copy, paste, spellcheck, and save-image are what the user actually wants.
  • Opened at the bottom or right edge of the window, the menu must flip back over the click point rather than extending beyond the viewport, and must never open partly off-screen on a second monitor arrangement.
  • The menu must reflect permissions on the specific record targeted, not on the collection. A row the user may view but not delete must not offer Delete and then fail.
  • Right-clicking a row inside a multi-selection should act on the whole selection, and right-clicking outside it should reset the selection to the clicked item — pick one rule and apply it everywhere.
  • Long-press is the touch equivalent, and if it is implemented it must not fire during a scroll gesture or a drag.
  • The menu must close when the underlying item is deleted or moved while it is open, rather than acting on a record that is no longer there.

Definition of done

9
  • Right-click opens a contextual menu only on the surfaces where it was deliberately added.
  • Every action in a context menu is also reachable from a visible control.
  • A keyboard shortcut opens the same menu for the focused item.
  • The native browser menu still appears in text fields, on selected text, on links, and on images.
  • The menu stays fully within the viewport when opened near any edge.
  • Menu items reflect the current user's permissions on the targeted record.
  • Item behaviour and dismissal are delegated to the dropdown menu primitive.
  • The feature matches the existing design system.
  • No existing functionality is broken.

Related features

How it works

  1. 1

    Copy the link

    Grab the Markdown instruction URL for this feature.

  2. 2

    Give it to your AI

    Paste it into Claude Code, Cursor, v0, Lovable — whatever you build with.

  3. 3

    It inspects, then implements

    Your agent reads your existing app first, then adds the feature to fit it.

Works with your stack

These instructions are written to adapt. They tell the agent to detect your framework, match your existing design system, and reuse what you already have — rather than assuming a particular stack.

Need it tighter than that? Customize the feature and tell it exactly what you're running.