Skip to content

test(ContextMenu): after a touch open, the first arrow key moves focus without focusVisible: false - #13965

Merged
cixzhang merged 2 commits into
mainfrom
lane4/contextmenu-touch-open-key-ring
Nov 29, 2026
Merged

cixzhang merged 2 commits into
mainfrom
lane4/contextmenu-touch-open-key-ring

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Maintainer impact

A keyboard user who arrives after a touch open (a tablet with a keyboard) needs the menu's focus ring once they press a key. architecture:interaction-modality INV1 says programmatic focus keeps the last input's modality: no indicator after pointer input, the indicator after keyboard input. In Chromium, MenuHoverFocus.a11y.chromium.spec.ts checks the shared ArrowDown path after a mouse open: the row ArrowDown reaches matches :focus-visible. No test covers a long-press open, whose own open focuses the first row with focusVisible: false, so nothing pins that the key after a touch open still asks for plain focus.

Intended invariant

After a long-press open, ContextMenu focuses its first row with focus({focusVisible: false}); the next ArrowDown moves focus to the next row without focusVisible: false. This jsdom case checks the focus call only; whether the browser then draws the ring is the Chromium spec's check.

Change

One case in packages/core/src/ContextMenu/ContextMenu.test.tsx, beside the long-press open case. No product code changes.

Evidence

  • The case passes on main (83 of 83 in the file). It records the behavior main already has: measured with a focus spy, the touch open focuses "Cut" with {focusVisible: false}, and ArrowDown focuses "Copy" with no options.

Scope

Overlap checked: #12732, #12226, #11569, #9816, #8201, #8133, #8125 (each changes other cases, or the menu's touch and press behavior, in ContextMenu.test.tsx; #12732 is a do-not-merge preview; this adds one independent case beside the long-press test, so whichever lands second keeps both)

  • No intended public API, product behavior, visual direction, or policy change.
  • Product changes discovered during the work were removed or split.
  • Public text and artifacts contain no internal Meta context.

Testing

  • pnpm exec vitest run --project ui packages/core/src/ContextMenu/ContextMenu.test.tsx (83 passed).
  • pnpm preflight --quick on this branch.

…s with the ring

A long-press open focuses the first row without the keyboard indicator, and
the next ArrowDown moves focus without focusVisible: false, so the browser
draws the ring after keyboard input.
@cixzhang cixzhang added the lane:4 Astryx fix-loop lane 4 owns this label Nov 28, 2026
@vercel

vercel Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 28, 2026 5:01pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 28, 2026
@astracat-bot

astracat-bot Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 28, 2026, 6:49 PM UTC

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 98fa299

@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · d6ea95c

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
ContextMenu · Storybook 111.0 kB (0) · 19.9 kB CSS (0) 754 (0) — · ✓ · ✓

Package size: no published package changed; no new dependencies.

Touched components checked; for the full suites, add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot Bot 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.

Changes requested: the new long-press case is sound and self-contained, but the pull request's text claims more than its tests show.

  • The description says nothing would catch a change that kept the ring hidden after the first key that follows a long-press open, but the ContextMenu case in MenuHoverFocus.a11y.chromium.spec.ts (lines 202-221, run on every pull request) already fails on a hidden ring after ArrowDown on a pointer-opened menu, so please narrow the sentence to the long-press open itself.
  • The title and the case name say the arrow key moves focus "with the ring", but the jsdom case can only assert that focus() gets no focusVisible: false, so rename both to what the case asserts, or add the key press to the touch long press in ContextMenuLongPress.a11y.chromium.spec.ts and assert :focus-visible there.

CI's test jobs were skipped on this draft head, so the case has not run in CI yet.

Claims and files checked

Review mode: full; reason: no-earlier-review

  • Title, after a touch open the first arrow key moves focus with the ring: unverified for the ring, since the case asserts only the focus options in jsdom and no real-browser case covers a touch open (finding above).
  • A keyboard user arriving after a touch open needs the ring once they press a key: verified against INV1 of the interaction-modality record.
  • INV1 says programmatic focus keeps the last input's modality: verified (record lines 140-142).
  • The ContextMenu unit file covered focus visibility only for a mouse open: verified (its only such assertion before this case is at line 206).
  • Nothing would catch a change that kept the ring hidden after the first key following a long-press open: false (MenuHoverFocus.a11y.chromium.spec.ts:202-221; focusReturn.test.ts:107) (finding above).
  • After a long-press open the first row is focused with focusVisible: false, and the next ArrowDown moves focus without it: verified by the code path (ContextMenu.tsx:477-485, useListFocus.ts:597-598, focusReturn.ts:239-257) and asserted by the case at lines 824-834; not yet run in CI.
  • So the browser draws the ring after keyboard input: unverified for a touch open (no real-browser case).
  • One case beside the long-press open case, with no product code changes: verified (one file, 38 added lines; the case at line 803 follows the one at line 780).
  • The case passes on main, 83 of 83 in the file: reported; CI test jobs were skipped on this head.
  • Measured with a focus spy, ArrowDown focuses "Copy" with no options: verified (focusForLastInput calls a plain focus() when it gets no options and the last input was a key).
  • The seven listed pull requests each change the same test file, and one is a do-not-merge preview: verified (all open; each changes ContextMenu.test.tsx; the preview's title says so).
  • Whichever lands second keeps both cases: reported.
  • No intended public API, product behavior, visual or policy change: verified.
  • Product changes found during the work were removed or split: reported.
  • Public text and artifacts carry no internal context: verified.
  • Testing, a Vitest run of the file (83 passed) and the quick preflight: reported.
  • File packages/core/src/ContextMenu/ContextMenu.test.tsx: finding (the case name at line 803 promises the keyboard indicator).

Automated review (maintainer link)

jsdom cannot show a focus ring; the case checks that the key after a touch
open asks for focus without focusVisible: false.
@cixzhang cixzhang changed the title test(ContextMenu): after a touch open, the first arrow key moves focus with the ring test(ContextMenu): after a touch open, the first arrow key moves focus without focusVisible: false Nov 28, 2026
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec d6ea95c

@astracat-bot astracat-bot Bot 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.

Approved pending CI: CI is still running on this head.

The new case pins that the first arrow key after a long-press open asks for plain focus, and the title, case name and description match what it asserts. The UI tests that run it pass on this head; nothing more is needed from you, and the remaining CI jobs still have to pass before merge.

Claims and files checked

Review mode: same-head; reason: none

  • changed rules (0): none
  • Live title, "test(ContextMenu): after a touch open, the first arrow key moves focus without focusVisible: false": verified by the code path (ContextMenu.tsx:482 and :641, useListFocus.ts:598, focusReturn.ts:239-257) and asserted by the case at ContextMenu.test.tsx:824-834, which passes in CI at this head.
  • A keyboard user who arrives after a touch open needs the ring once they press a key: verified against INV1 of the interaction-modality record.
  • INV1 says programmatic focus keeps the last input's modality, with no indicator after pointer input and the indicator after keyboard input: verified (record lines 140-142).
  • In Chromium, the menu hover-focus spec checks the shared ArrowDown path after a mouse open, and the row ArrowDown reaches matches :focus-visible: verified (MenuHoverFocus.a11y.chromium.spec.ts:202-221).
  • No test drives that key path after a long-press open, so nothing pins that the key asks for plain focus: verified (all 49 test files that mention ContextMenu listed; the 8 with touch and key input read; none presses a key after a ContextMenu touch open).
  • After a long-press open the first row takes focus with focusVisible false, and the next ArrowDown moves focus without it: verified by the code path and asserted by the case.
  • The jsdom case checks only the focus call, and drawing the ring is left to the browser: verified (the case asserts focus options at lines 824-834 and nothing about :focus-visible).
  • One case in the ContextMenu unit file, beside the long-press open case, with no product code changes: verified (one file, 38 added lines; the case at line 803 follows the one at line 780).
  • The case passes on main, 83 of 83 in the file: reported, and CI's UI run at this head passes the file's 83 tests.
  • Measured with a focus spy, the touch open focuses Cut with focusVisible false, and ArrowDown focuses Copy with no options: verified (useListFocus.ts:598 passes no options, and focusReturn.ts:240-241 then calls focus() with no arguments).
  • The seven listed pull requests each change the same test file, and one is a do-not-merge preview: verified (each one's file list includes it; the preview's title says so).
  • Whichever lands second keeps both cases: reported.
  • No intended public API, product behavior, visual direction or policy change: verified.
  • Product changes found during the work were removed or split: reported.
  • Public text and artifacts contain no internal context: verified.
  • Testing, a Vitest run of the file (83 passed) and the quick preflight: reported.
  • File packages/core/src/ContextMenu/ContextMenu.test.tsx: clear.

Automated review (maintainer link)

@cixzhang
cixzhang marked this pull request as ready for review November 28, 2026 18:33
@cixzhang
cixzhang merged commit 80f6630 into main Nov 29, 2026
156 checks passed
@github-actions
github-actions Bot deleted the lane4/contextmenu-touch-open-key-ring branch November 29, 2026 06:08

This branch was successfully deployed

1 active deployment
Preview — d6ea95c2 Deployed Nov 28, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. lane:4 Astryx fix-loop lane 4 owns this

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant