Skip to content

[AGILE-348] Show the card ActionMenu as a context menu - #24464

Open
myabc wants to merge 3 commits into
devfrom
implementation/AGILE-348-card-context-menu
Open

[AGILE-348] Show the card ActionMenu as a context menu#24464
myabc wants to merge 3 commits into
devfrom
implementation/AGILE-348-card-context-menu

Conversation

@myabc

@myabc myabc commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Ticket

https://community.openproject.org/wp/AGILE-348

What are you trying to accomplish?

Right-clicking a Backlogs work-package card now opens that card's own ActionMenu at the pointer, instead of the browser's native context menu. The same menu is reachable from the keyboard with Shift+F10 or the Context Menu key, and the card advertises this via aria-keyshortcuts="Enter Shift+F10".

  • Focus returns to the card when the menu closes.
  • Touch and pen input keep the platform's native long-press behaviour.
  • Right-clicking the "More" button opens the menu anchored on the button, as it already did.

Screenshots

Context Menu Action Menu (via ... button) Context Menu (via Shift+F10)
Screenshot 2026-07-29 at 09 42 47 Screenshot 2026-07-29 at 09 48 22 Screenshot 2026-07-29 at 09 48 15

What approach did you choose and why?

Three layers, so nothing Backlogs-specific leaks into the generic pieces:

  1. Presenter (frontend/src/common/contextual-action-menu.ts) — framework-agnostic; opens a Primer ActionMenu overlay at a point or at its invoker, borrows and restores the overlay's anchoring state, and restores focus on close.
  2. Stimulus controller (contextual-action-menu.controller.ts) — wires contextmenu / keyboard entry points onto any element, and emits a cancelable contextual-action-menu:beforeOpen so hosts can opt out.
  3. Backlogs card — opts in by adding the controller alongside its existing ones.

Merge checklist

  • Added/updated tests
  • Added/updated documentation in Lookbook (patterns, previews, etc)
  • Tested major browsers (Chrome, Firefox, Edge, ...)

@myabc
myabc requested a review from Copilot July 27, 2026 18:17
@myabc myabc added DO NOT MERGE javascript Pull requests that update Javascript code feature labels Jul 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a reusable, framework-agnostic “contextual action menu” implementation and wires it into Backlogs work package cards so the existing Primer ActionMenu can be opened via right-click (pointer) and Shift+F10 / Context Menu key (keyboard), while preserving native context menus for interactive descendants and touch long-press.

Changes:

  • Introduces ContextualActionMenu presenter (shared, framework-agnostic) and a Stimulus controller to invoke it contextually (pointer + keyboard), including cleanup across morph/turbo-stream updates.
  • Wires Backlogs work package cards to opt into the new controller and exposes page-object helpers for Selenium feature coverage.
  • Adds comprehensive frontend unit tests (Vitest) and Backlogs Selenium feature specs to cover focus/anchoring/gesture edge cases.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
modules/backlogs/spec/support/pages/backlog.rb Adds page-object helpers/selectors for contextual menu interaction and assertions; refactors overlay selector reuse.
modules/backlogs/spec/features/work_packages/card_context_menu_spec.rb New Selenium feature spec verifying contextual open, focus behavior, keyboard invocation, and anchor restoration.
modules/backlogs/spec/components/backlogs/work_package_card_list_item_component_spec.rb Extends component specs to assert the new controller wiring and updated aria-keyshortcuts.
modules/backlogs/app/components/backlogs/work_package_card_list_item_component.rb Wires contextual-action-menu Stimulus controller onto Backlogs cards and updates ARIA key shortcuts.
frontend/tsconfig.json Adds core-common/* path alias for shared, framework-agnostic modules under src/common/.
frontend/src/stimulus/controllers/dynamic/contextual-action-menu.controller.ts New Stimulus controller handling pointer + keyboard invocation, native-menu fallthrough rules, and morph-safe presenter lifecycle.
frontend/src/stimulus/controllers/dynamic/contextual-action-menu.controller.spec.ts New unit tests covering ordering differences (macOS vs Windows/Linux), echo suppression, cancellation, morph swaps, and disconnect cleanup.
frontend/src/common/contextual-action-menu.ts New presenter that re-anchors Primer ActionMenu overlays contextually, restores overlay state, and returns focus appropriately.
frontend/src/common/contextual-action-menu.spec.ts Unit tests for presenter anchoring, state restoration, focus restoration, and destroy cleanup.
frontend/AGENTS.md Documents src/common/ as the home for framework-agnostic modules (core-common alias).

@myabc myabc changed the title Implementation/agile 348 card context menu [AGILE-348] Show the card ActionMenu as a context menu Jul 27, 2026
@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown

Deploying openproject with PullPreview

Field Value
Latest commit 007f09f
Job deploy
Status ✅ Deploy successful
Preview URL https://pr-24464-agile-348-card-c-ip-157-90-246-145.my.opf.run:443

View logs

@myabc
myabc force-pushed the implementation/AGILE-348-card-context-menu branch from 6f0ec5f to 70245cf Compare July 28, 2026 22:02
@myabc
myabc marked this pull request as ready for review July 28, 2026 22:03
@myabc myabc added this to the 17.8.x milestone Jul 28, 2026
@github-actions

Copy link
Copy Markdown

Caution

The provided work package version does not match the core version

Details:

Please make sure that:

  • The work package version OR your pull request target branch is correct

Comment on lines +33 to +47
// Mirrors the members of Primer's `AnchoredPositionElement` that the presenter
// drives — including the quirk that gives this spec its teeth: `anchorOffset`
// reads its attribute as an enum (only `spacious`/`8` mean 8), so an arbitrary
// pixel offset can only reach `getAnchoredPosition` as a property.
//
// The accessors deliberately live on a prototype. The presenter carries the
// vertical offset as an *own* property shadowing `anchorOffset`, and a fake
// that defined its accessors per instance would be overwritten rather than
// shadowed, leaving the restore with nothing to undo and nothing to prove.
//
// `update()` runs the real `getAnchoredPosition`, with the element itself as
// the settings object, exactly as the production element does. The offsets
// this spec asserts on are therefore read the way Primer reads them, rather
// than the way this spec wishes they were read.
class FakeAnchoredPositionElement extends HTMLElement {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should just import the real AnchoredPositionElement? Not sure how "unit"-ey frontend specs should be.

myabc added 3 commits July 29, 2026 00:34
Primer's ActionMenu opens at its trigger button; presenting one at a
pointer position means re-anchoring the overlay and restoring it after.
It lands in `src/common/` because the Angular card lists will want the
same behaviour.

https://community.openproject.org/wp/AGILE-348
Attaches contextual entry points — right-click, Shift+F10, the Context
Menu key — to any element that already owns an action menu, without
touching that element's own behaviour. Its cancelable `beforeOpen` event
is the seam a later batch-selection slice needs.

https://community.openproject.org/wp/AGILE-348
Right-clicking a backlog card is the gesture people reach for, and the
card already carries the menu its More button opens. Non-movable cards
opt in too: their one action is still worth reaching contextually.

https://community.openproject.org/wp/AGILE-348
@myabc
myabc force-pushed the implementation/AGILE-348-card-context-menu branch from 70245cf to 007f09f Compare July 28, 2026 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature javascript Pull requests that update Javascript code needs review pullpreview

Development

Successfully merging this pull request may close these issues.

2 participants