LearnNewsExamplesConnect
Frontmatter
assigneesneo-opus-ada
createdAtOct 21, 2026, 3:42 PM
updatedAtOct 21, 2026, 7:02 PM
githubUrlhttps://github.com/neomjs/neo/issues/19961
authorneo-opus-ada
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtOct 21, 2026, 7:02 PM

A header menu's late search focus pulls focus off the value just picked

Closed v13.3.1/archive-v13-3-1-chunk-1 bugaigridaccessibility
neo-opus-ada
neo-opus-ada commented on Oct 21, 2026, 3:42 PM

Correction (2026-10-21, before the PR): this body first presented the race below as the cause of the #19928 arm's e2e-engine flake. The race is real: a held-focus e2e shows it deterministically, red on base and green with the fix. But it is not the arm's only cause. Under the same conditions, the arm still failed 2 of 16 runs at head and 1 of 16 on base, with the same symptom. AC-3 is narrowed accordingly, and the arm's remaining cause is out of scope here.

Context

The #19928 arm in test/playwright/e2e/grid/IssuesShowcase.spec.mjs ("the filter list draws its focus ring inside the row and its rows on the menu surface, in both themes") fails intermittently in e2e-engine (3/4). It failed on the first runs of #19958 and #19960: .neo-navigator-active-item is not found after a pick. @neo-gemini-maryam traced one mechanism (A2A, 2026-10-21): a late search focus that pulls focus off the value just picked.

The Problem

Opening a header menu focuses its search field one worker↔main round trip after the surface shows. Two calls did it: Menu#open() explicitly, and the floating container's own focusOnMount (Component#afterSetMounted pushes focus to the first focusable child). A pointer that picks a value inside that window gets focus first. The late focus then moves it to the search field, and Neo.main.addon.Navigator removes .neo-navigator-active-item on focusout. The pick still applies, but the active state the user just set is gone.

The Architectural Reality

  • src/grid/header/plugin/Menu.mjs#open(): this.surface.hidden = false; await this.surface.promiseUpdate(); then the search focus. The surface also kept the floating default focusOnMount: true.
  • src/main/addon/Navigator.mjs adds the active-item class on focusin and removes it on focusout.
  • A worker-side guard such as surface.containsFocus narrows the race but cannot close it, because the user's focusin can still be in flight when promiseUpdate() resolves. The decision belongs on the main thread, at the moment the focus call lands.
  • Design authority: Menu#open()'s own JSDoc, "Opens the same surface from pointer, touch or keyboard". The initial search focus serves an opener that hasn't chosen yet, and it must not override a pointer that already has.

The Fix

  • DomAccess.focus gains unlessFocusWithin: the id of a container whose current focus wins.
  • Menu#open() becomes the surface's single focus owner: the surface sets focusOnMount: false, and open() focuses the search input with unlessFocusWithin: surface.id.
  • Opening with no intervening pick keeps today's search focus.

Acceptance Criteria

  • AC-1: A value picked right after opening, before the menu's search focus would land, keeps focus and its active-item state.
  • AC-2: Opening without a pick still focuses the search field, so the keyboard path is unchanged.
  • AC-3: A browser e2e drives the pick inside that window deterministically, by holding the menu's focus call on the main thread, and is red on base and green at head.

Out of Scope

  • The #19928 arm's remaining flake. Another cause produces the same symptom; my earlier hypothesis is a click that lands before the Navigator's listeners re-bind after the theme switch.
  • The same mount-focus race for other floating components (noted separately).
  • #19955, #19953 and #19954.

Related

#19928 (the arm) · #19929 · #19958 and #19960 (the flaky runs)

Live latest-open sweep: checked the latest 20 open issues at 2026-10-21T13:41:44Z; no equivalent found. Exact search "Menu open focus search value": none. A2A sweep: Maryam's root-cause note is FYI with no claim; no other claim on this. MC sweep: covered by my own handover note on this flake (a lost active-item class was one of its two hypotheses); no prior decision. Own-assignment sweep: none overlapping (#19955 is the header scroll).

Origin Session ID: 93bb60cd-9a62-43b7-a8e0-25091f9af03f

Retrieval Hint: "header menu late search focus steals focus from picked value, navigator active item focusout, focusOnMount"

tobiu referenced in commit 8ebf5a4 - "fix(grid): a value picked before the menu's search focus lands keeps its focus (#19961) (#19962) on Oct 21, 2026, 7:02 PM
tobiu closed this issue on Oct 21, 2026, 7:02 PM