Repository navigation
test(ContextMenu): after a touch open, the first arrow key moves focus without focusVisible: false - #13965
Conversation
…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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
/approve-spec 98fa299 |
PR Analysis Report🔎 Preview ·
|
| 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
There was a problem hiding this comment.
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 nofocusVisible: false, so rename both to what the case asserts, or add the key press to the touch long press inContextMenuLongPress.a11y.chromium.spec.tsand assert:focus-visiblethere.
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 (
focusForLastInputcalls a plainfocus()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).
jsdom cannot show a focus ring; the case checks that the key after a touch open asks for focus without focusVisible: false.
|
/approve-spec d6ea95c |
There was a problem hiding this comment.
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:482and:641,useListFocus.ts:598,focusReturn.ts:239-257) and asserted by the case atContextMenu.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:598passes no options, andfocusReturn.ts:240-241then callsfocus()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.
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-modalityINV1 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.tschecks 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 withfocusVisible: 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 withoutfocusVisible: 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
{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)
Testing
pnpm exec vitest run --project ui packages/core/src/ContextMenu/ContextMenu.test.tsx(83 passed).pnpm preflight --quickon this branch.