LearnNewsExamplesConnect
Frontmatter
assigneesneo-opus-grace
createdAtNov 14, 2026, 6:13 PM
updatedAtNov 15, 2026, 12:29 AM
githubUrlhttps://github.com/neomjs/neo/issues/20952
authorneo-opus-grace
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtNov 15, 2026, 12:29 AM

A tab press in another tabs node loses its focus to the previous tab

Closed v14.0.0/archive-v14-0-0-chunk-2 bugaicoreaccessibility
neo-opus-grace
neo-opus-grace commented on Nov 14, 2026, 6:13 PM

Context

In the engine Workstation (apps/workstation, dev b52fd886e6), press a tab in one tabs node, then a tab in another node. About 100 ms later, focus is back on the first tab.

Measured in Chromium at 1600×1000. The page logged focusin; revertFocus and Reconciler.reconcileProjection were wrapped in the App worker over CDP.

  • 926 ms: press activity in heavy-tabs. Focus enters its tab button.
  • 1,759 ms: press audit in right-top-tabs. Focus enters its button.
  • 1,855 ms: focus is back on activity's button. In between, the dock refresh that the second press committed destroyed three containers that still held containsFocus. Each one's revertFocus() focused its focusEnterData.relatedTarget: the first tab.

Both presses committed full rebuilds: reconcileProjection ran with retainTopology and geometryOnly false, and returned landedInPlace: false.

The Problem

  • The user's choice is taken back. The pressed tab loses focus to the one pressed before it.
  • The focus-gated header actions leave with it. A tab header's pop-out, maximize and close are focus-gated. contextualActionsVisible follows the tab container's containsFocus (src/toolbar/Base.mjs:568). After the revert, the second node's actions leave the DOM again: a pointer user loses the action they were about to press, and a keyboard user loses their place.
  • The window is short, so it reads as flakiness. The actions appear for about 100 ms after the press, then withdraw. A test that polls every 25–100 ms usually catches them; one that waits longer, or runs while the App worker is busy, does not.

The Architectural Reality

  • Component#revertFocus (src/component/Base.mjs:1944) focuses focusEnterData.relatedTarget through that component's own focus() while containsFocus is true. It runs on destroy (:1436), on unmount (:847) and on show (:605).
  • focus() is routed by three overrides: form/field/Select and form/field/Text focus their input element, and list/Base navigates through main.addon.Navigator.
  • Workspace#refreshDockWorkspace (src/dashboard/dock/Workspace.mjs:2675) runs Reconciler.reconcileProjection (src/dashboard/dock/projection/Reconciler.mjs:463). That call moves the surviving tab container into a new shell and destroys the old containers through container.remove (:678). The destroyed containers were ancestors of the pressed tab.
  • Order: destroy() reverts first and its DOM removal follows in a later delta. So when the focus request reaches the main thread, the departing containers still contain the new focus. A guard that reads the DOM at that moment cannot tell this case from a real loss.
  • Design authority: "A worker decides focus one round trip late, so a choice the user made in between, such as a picked list item, would otherwise be taken back." (DomAccess#focus, the unlessFocusWithin JSDoc, src/main/DomAccess.mjs:369–371). #18927 holds the same rule for a reprojected editor.

The Fix

  1. Decide after the departure. revertFocus() asks the main thread to settle first. Once the departing element has left the document, or a short bound has passed, focus counts as lost only if it fell to the body. Only then does the revert call the target component's focus(), so the three overrides still route it. A focus the user moved elsewhere stays where it is.
  2. Keep the revert where it belongs. A component destroyed with the focused element inside still hands focus back. These are the cases of #18847 and #18850.
  3. The show path (afterSetHidden, :605) reverts when a component becomes visible. The PR states whether it shares the settle, since nothing departs there.

Contract Ledger

Target surface Source of authority Proposed behavior Fallback Docs Evidence
Neo.main.DomAccess, a new settle read the unlessFocusWithin JSDoc of focus() resolves once a given element has left the document (or a bound passes) and reports whether focus fell to the body element already gone: decide at once the method's JSDoc a unit arm per branch
Component#revertFocus its call sites in src/component/Base.mjs focuses relatedTarget only when the settle reports a loss none its JSDoc the e2e below

Acceptance Criteria

  • Workstation e2e. Press a tab in one node, then a tab in another. 500 ms later, focus is still on the second tab, and its node's focus-gated actions are on the rail. It fails on dev first.
  • Unit arms. A departure that leaves the user's new focus alive sends no focus. A departure whose focus fell to the body still focuses relatedTarget, through the target's own focus().
  • Existing focus specs pass: the arms of #18847, #18850 and #18927.

Out of Scope

  • Why an active-tab change commits a full rebuild (retainTopology: false). It costs a shell per press, and it is the dock's call; I asked its owner separately.

Avoided Traps

  • Checking containsFocus in the worker before reverting: it lags the DOM by a round trip. #18927 measured the same lag.
  • A guard that reads the DOM when the request arrives: the departing container still holds the new focus then (see Order).
  • Restoring focus to relatedTarget's DOM id directly: it bypasses the overrides that route a field's or a list's focus.
  • Dropping revertFocus() from destroy: a destroyed component that held focus must still hand it back.
  • Waiting in tests: that hides a defect users hit.

Related

#18927, #18850, #18847, #20046, #19983

Live latest-open + closed sweep:

  • Open: the latest 20 (47 open, orange band). No owning ticket or epic.
  • Closed: searches for revertFocus, "focus tab back dock refresh" and "focus-gated header action tab press", at 17:11Z Nov 14. No equivalent. I read the same-surface hits: #18927 (Fix, AC-1), #18850 (Fix, Out of Scope, Avoided Traps), #20046 (Out of Scope), and #19186, which concerns a parked vessel. None covers the destroyed ancestors of a reprojection.
  • A2A claims (all read states, to 17:07Z): none on dock or tab focus.
  • Memory Core: adjacent prior work only (the overflow tab-press hold).
  • My own assignments: #20911, #20884 and #20790 do not touch focus.

Body corrected (author, 17:2xZ): the first Fix had the guard read the DOM when the request arrives. The Order line above shows why that cannot work.

Retrieval Hint: "tab press focus returns to previous tab dock refresh revertFocus destroyed ancestor containsFocus focus-gated header actions settle after departure"

tobiu referenced in commit 7698a7a - "feat(component): a departing component hands focus back only to a lost focus (#20952) (#20955) on Nov 15, 2026, 12:29 AM
tobiu closed this issue on Nov 15, 2026, 12:29 AM