# Bug DREAM-987 - ActionMenu steals focus back from an element clicked or tabbed to while it closes

Project: Stream Design System
Status: merged
URL: https://community.openproject.org/work_packages/DREAM-987

## Open points

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Module | Frontend components and Primer design system |
| Target versions | 18.0.0 |
| Observed in versions | 18.0.0 |
| Sprint |  |
| Backlog bucket |  |
| Bug found in version (deprecated) |  |
| Requires doc change | No |
| Accessibility | No |
| Pull preview |  |
| List |  |
| Labels |  |

## People

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable |  |
| Product manager |  |
| Developers | Alexander Coles |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Planning

| Attribute | Value |
| --- | --- |
| Relevance |  |

## Costs

| Attribute | Value |
| --- | --- |
| Votes |  |
| Work |  |
| Labor costs |  |

## Description

### Before filing a report

Reproduced the outside-click failure in Chrome on QA Stage on 8 November 2026.

### Steps to reproduce

1.  Sign in as a project administrator and open [Project settings → Information for 123 - New project](https://qa.openproject-stage.com/projects/NEWPR/settings/general).
2.  Click the **More** ( **…** ) button in the page header. The menu opens and **Add subproject** receives focus.
3.  Click inside the **Name** text field under **Basic details**.

### What is the buggy behavior?

The menu closes, but keyboard focus jumps to **More**. The **Name** field has no caret. A second click is needed before typing in the field.

### What is the expected behavior?

The menu closes and the **Name** field keeps focus, so the user can type after one click.

### Important note

Pressing **Tab** from the open menu moved focus to the **Show help text** link beside **Name** in this fixture. The outside-click path reproduced twice. The table column-menu case discussed below belongs to the work in <mention class="mention" data-id="DREAM-982" data-type="work_package" data-text="#DREAM-982">#DREAM-982</mention>.

### **Logs**

The result was verified by inspecting browser focus. No console output was captured.

### Screenshots and other files

No files attached for this reproduction.

### Environment information

  - **OpenProject installation type** — Hosted QA Stage.
  - **OpenProject version** — 18.0.0, core build `4ba13f725d75cee626f6e297b6bd2a6385d6cb14`.
  - **Browser** — Chrome.
  - **Operating system** — macOS.
  - **Language** — English application UI.

## Developer context

The opf Primer View Components fork's `<action-menu>` returns focus to its invoker whenever the primary overlay closes and no other popover is open (`#handleToggleEvent` in `action_menu_element.js`, fork-only: "A light-dismissed menu leaves focus on the body; hand it back to the invoker so the menu stays reachable from the keyboard"). The call is unconditional: it does not check that focus actually landed on the body.

When the user closes the menu by clicking an interactive element elsewhere, or tabs out of it, that element receives focus first and the toggle handler then pulls focus back to the menu button. In the work package table (<mention class="mention" data-id="DREAM-982" data-type="work_package" data-text="#DREAM-982">#DREAM-982</mention>, <https://github.com/opf/openproject/pull/26723>) a click on a row cell while a column menu is open focuses the cell and then yanks focus to the column header. Until the fork is fixed, the Angular `op-action-menu` component records the active element before the close and restores it afterwards; that workaround is marked inline and goes once this bug is fixed.

## Goal

`<action-menu>` hands focus back to its invoker only when the close left focus on the body. Focus that the user moved deliberately, by click or by **Tab**, stays where it went.

## Notes

  - Fix in the opf fork: the refocus only happens when focus was lost to the body or is still in the closed menu. Merged with <mention class="mention" data-id="AGILE-481" data-type="work_package" data-text="#AGILE-481">#AGILE-481</mention> (<https://github.com/opf/primer_view_components/pull/551>), not yet released.
  - System tests in the fork (outside click on a focusable element, outside click on plain text, **Tab**): <https://github.com/opf/primer_view_components/pull/557>
  - Removal of the workaround in `op-action-menu.component.ts`, together with the version bump once released: <https://github.com/opf/openproject/pull/26983>
  - Timing: after the 18.0 feature freeze (2026-11-11), before the 18.0 release.
