Skip to content

fix(DropdownMenu): focus first item on pointer open - #11297

Open
bezabyte wants to merge 8 commits into
meta:mainfrom
bezabyte:fix/issue-9000-menu-open-focus
Open

bezabyte wants to merge 8 commits into
meta:mainfrom
bezabyte:fix/issue-9000-menu-open-focus

Conversation

@bezabyte

@bezabyte bezabyte commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #9000

What changed

Opening an anchored DropdownMenu or MoreMenu popover with a pointer now focuses the first enabled item, matching keyboard opens and the ARIA menu-button pattern. If the pointer has already reached a valid row, that row keeps focus; the menu container remains the fallback when no item can receive focus.

This change is limited to the anchored popover presentation. Bottom-sheet presentations keep their existing focus behavior.

Pointer focus still goes through the shared last-input focus path, so the row is focused for assistive technology without drawing a keyboard-only focus ring. Because the focused first row also receives the existing :focus hover overlay, the open popover can show that row's normal focus/hover treatment; no new visual treatment was added.

Testing

  • pnpm exec vitest run packages/core/src/DropdownMenu/DropdownMenu.test.tsx packages/core/src/DropdownMenu/DropdownMenuSubMenu.test.tsx packages/core/src/MoreMenu/MoreMenu.test.tsx packages/core/src/Toolbar/Toolbar.test.tsx --project ui --reporter dot — 383 passed
  • Repository pre-commit checks passed

The changeset is in .changeset/dropdown-menu-pointer-focus.md. Follow-up source-comment cleanup is included in 54b770ce2.

@vercel

vercel Bot commented Nov 11, 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 14, 2026 7:17pm UTC

Request Review

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

astracat-bot Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
❓ Needs maintainer input (for maintainers only) Nov 27, 2026, 12:15 PM UTC

@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Nov 11, 2026

@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.

Thanks for picking up #9000: focusing the first row on a pointer open gives screen-reader users a current item, as a keyboard open already does. Approval waits on an engineering owner deciding the direction: the current MoreMenu record (docs/specs/components/MoreMenu/MoreMenu.spec.md, AR1) says a pointer open focuses the menu container and the first ArrowDown moves to the first row, and the DropdownMenu record does not cover the root menu's pointer open, so an engineering owner needs to approve amending that record (the amendment can ride in this pull request) and record the decision by commenting /approve-spec <full head SHA> (the author may do this if they are an engineering owner).

These need changes whatever the decision:

  • Tests that still expect the menu container to be focused after a pointer open will fail: DropdownMenuSubMenu.test.tsx (the openRoot and openExport helpers and six direct waits), two MoreMenu cases in Toolbar.test.tsx, and the Chromium specs MenuHeaderFooter.a11y.chromium.spec.ts, MenuPress.a11y.chromium.spec.ts and DropdownMenuAudit.a11y.chromium.spec.ts.
  • DropdownMenu.tsx:1223 now moves focus to the first row even when the pointer lit another row before the open frame, so the highlight leaves the row under the pointer while a held press still acts on that row; keep the base's check that skips focusEnd() when a row in the list already has focus.
  • The description says the visible appearance is unchanged, but menu rows paint their hover overlay on :focus (DropdownMenuItem.tsx:72), so the first row looks highlighted right after a mouse open; please say so in the description or keep that overlay off for pointer-opened focus.
  • No Changeset names @astryxdesign/core, which the changeset coverage check requires for shipped source; add one with pnpm changeset:new --packages @astryxdesign/core --category fix.

CI has not run on this head yet.

Claims and files checked
  • Claim: a pointer open of DropdownMenu or MoreMenu focuses the first enabled item: verified (DropdownMenu.tsx:1219-1227 and the updated tests).
  • Claim: this matches keyboard opens and the menu-button pattern: verified for keyboard parity; it conflicts with the current MoreMenu record.
  • Claim: the menu stays the fallback when no item can take focus: verified (DropdownMenu.tsx:1223-1226).
  • Claim: pointer focus shows no keyboard-only ring: verified (the shared helper passes focusVisible: false).
  • Claim: the visible menu appearance is unchanged: false (rows paint their overlay on :focus).
  • Claim: the regression test checks the focused item and the focusVisible: false request: verified (DropdownMenu.test.tsx:2689-2699).
  • Claim: the listed test runs cover the change: incomplete (the DropdownMenuSubMenu, Toolbar and Chromium suites above are not in the list).
  • packages/core/src/DropdownMenu/DropdownMenu.tsx: finding (line 1223 overrides a pointer-lit row).
  • packages/core/src/DropdownMenu/DropdownMenu.test.tsx: finding (lines 2719-2742 assert that override; line 4677 checks only the menu's ring).
  • packages/core/src/MoreMenu/MoreMenu.test.tsx: finding (lines 302-331 flip the tests behind the current MoreMenu record; waits on the owner decision).

Automated review (maintainer link)

});

it('pointer open focuses the menu container, not the first item (#4477)', async () => {
it('pointer open focuses the first enabled item (#9000)', async () => {

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.

The current MoreMenu record (docs/specs/components/MoreMenu/MoreMenu.spec.md, AR1) says a pointer open focuses the menu container and the first ArrowDown moves to the first row; these two tests now assert the opposite, so they wait on the owner decision and the record amendment.

@bezabyte

Copy link
Copy Markdown
Contributor Author

Pushed cd4308d with the requested review updates. The full focused-menu suite now passes (383/383), including the submenu, MoreMenu, Toolbar, and a11y expectation updates. I also corrected the PR description to document the existing first-row focus/hover overlay rather than claiming the appearance is unchanged. Reviewer requests for cixzhang, imdreamrunner, and josephfarina remain attached; the owner/spec decision is still the only non-code gate.

@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.

Thanks for the quick follow-up: the stale container-focus tests, the pointer-lit row, the description and the missing Changeset from the last review are all addressed. Approval still waits on an engineering owner deciding the direction: the current MoreMenu record (docs/specs/components/MoreMenu/MoreMenu.spec.md, AR1) says a pointer open focuses the menu container and the first ArrowDown moves to the first row, and the DropdownMenu record does not cover the root menu's pointer open, so an engineering owner needs to approve amending that record (the amendment can ride in this pull request) and record the decision by commenting /approve-spec <full head SHA> (the author may do this if they are an engineering owner).

These need attention whatever the decision:

  • The Changeset's @cixzhang, @imdreamrunner and @josephfarina lines are its contributor credit, which the changelog renders as "thanks …", so the release notes would credit reviewers instead of you; replace them with @bezabyte.
  • Non-blocking: the test "a row the pointer lit before the open frame keeps focus" lights Edit, which is also the first row, so it passes with the lit-row check removed; light Duplicate instead so it guards that behavior.

CI has not run on this head yet.

Claims and files checked
  • Claim: a pointer open of DropdownMenu or MoreMenu focuses the first enabled item: verified (DropdownMenu.tsx:1233 and the updated tests).
  • Claim: this matches keyboard opens and the menu-button pattern: verified for keyboard parity; it conflicts with the current MoreMenu record.
  • Claim: a row the pointer already reached keeps focus: verified in code (DropdownMenu.tsx:1226-1235); its test does not tell the two apart.
  • Claim: the menu stays the fallback when no item can take focus: verified (DropdownMenu.tsx:1233-1235).
  • Claim: pointer focus goes through the shared last-input path, with no keyboard ring: verified (focusFollowsLastInput and the focusVisible: false request).
  • Claim: the first row shows the existing focus/hover overlay and no new visual treatment was added: verified (rows paint on :focus; no style changed).
  • Claim: the listed test runs and pre-commit checks passed: not reproduced in this review; CI has not run.
  • Claim: the Changeset is .changeset/dropdown-menu-pointer-focus.md and describes the change: verified.
  • Claim: the Changeset's contributor lines name the contributors: false (see above).
  • .changeset/dropdown-menu-pointer-focus.md: finding (contributor lines).
  • packages/core/src/DropdownMenu/DropdownMenu.tsx: waits on the owner decision; small comment suggestions.
  • packages/core/src/DropdownMenu/DropdownMenu.test.tsx: non-blocking (the lit-row test uses the first row).
  • packages/core/src/DropdownMenu/DropdownMenuSubMenu.test.tsx: clear.
  • packages/core/src/DropdownMenu/__tests__/DropdownMenuAudit.a11y.chromium.spec.ts: clear.
  • packages/core/src/DropdownMenu/__tests__/MenuHeaderFooter.a11y.chromium.spec.ts: clear.
  • packages/core/src/DropdownMenu/__tests__/MenuPress.a11y.chromium.spec.ts: clear.
  • packages/core/src/MoreMenu/MoreMenu.test.tsx: waits on the owner decision (these tests encode the new behavior).
  • packages/core/src/Toolbar/Toolbar.test.tsx: clear.

Automated review (maintainer link)

@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.

The two fixes asked for in the last review are in: the Changeset now credits you, and the lit-row test lights Duplicate, so it guards the restored check. Approval waits on an engineering owner deciding the direction: the current MoreMenu record (docs/specs/components/MoreMenu/MoreMenu.spec.md, AR1) says a pointer open focuses the menu container and the first ArrowDown moves to the first row, and the DropdownMenu record does not cover the root menu's pointer open. An engineering owner records that decision, and can approve amending the record in this pull request, by commenting /approve-spec <full head SHA>; the author may do so if they are an engineering owner. CI has not run on this head yet; a maintainer adds the ci:run label so it runs.

  • Non-blocking: comments in DropdownMenu.tsx (lines 26-28, 1156-1157, 1209-1216 and 1777-1778) still describe every open as landing on the first row, or the menu as a fallback where it is a Tab stop; shorter wording is suggested inline for lines 28 and 1156.
Claims and files checked
  • Claim: a pointer open of DropdownMenu or MoreMenu focuses the first enabled item: verified (DropdownMenu.tsx:1233 and the updated tests).
  • Claim: this matches keyboard opens and the menu-button pattern: verified for keyboard parity; it conflicts with the current MoreMenu record.
  • Claim: a row the pointer already reached keeps focus: verified (DropdownMenu.tsx:1226-1235; the lit-row test now uses a row other than the first).
  • Claim: the menu stays the fallback when no item can take focus: verified (DropdownMenu.tsx:1233-1235).
  • Claim: pointer focus goes through the shared last-input path, with no keyboard ring: verified (focusFollowsLastInput and the focusVisible: false request checked in DropdownMenu.test.tsx:2698).
  • Claim: the first row shows the existing focus/hover overlay and no new visual treatment was added: verified (rows paint on :focus; no style changed).
  • Claim: the listed test runs and pre-commit checks passed: not reproduced; CI has not run.
  • Claim: the Changeset is .changeset/dropdown-menu-pointer-focus.md and describes the change: verified.
  • Claim: the Changeset credits the contributor: verified (@bezabyte).
  • .changeset/dropdown-menu-pointer-focus.md: clear.
  • packages/core/src/DropdownMenu/DropdownMenu.tsx: waits on the owner decision; small comment suggestions.
  • packages/core/src/DropdownMenu/DropdownMenu.test.tsx: clear.
  • packages/core/src/DropdownMenu/DropdownMenuSubMenu.test.tsx: clear.
  • packages/core/src/DropdownMenu/__tests__/DropdownMenuAudit.a11y.chromium.spec.ts: clear.
  • packages/core/src/DropdownMenu/__tests__/MenuHeaderFooter.a11y.chromium.spec.ts: clear.
  • packages/core/src/DropdownMenu/__tests__/MenuPress.a11y.chromium.spec.ts: clear.
  • packages/core/src/MoreMenu/MoreMenu.test.tsx: waits on the owner decision (these tests encode the new behavior).
  • packages/core/src/Toolbar/Toolbar.test.tsx: clear.

Automated review (maintainer link)

@bezabyte

Copy link
Copy Markdown
Contributor Author

I checked the latest review at d430ba21f13ed0cfde9d08326c9e3adb7602bc01.

All implementation findings are addressed: the pointer-lit row keeps focus, the changeset credits @bezabyte, the visible first-row focus overlay is documented, and the focused menu suite passes 383/383. The remaining review note is documentation-only wording in existing comments; no behavior change is needed.

The PR still needs the engineering-owner decision on the MoreMenu/DropdownMenu focus contract and the maintainer ci:run action.

@bezabyte

Copy link
Copy Markdown
Contributor Author

Also addressed the remaining non-blocking review note in `c76f391bb): clarified the source comments so they describe the actual pointer-open behavior (preserve the pointer-lit row when present, otherwise focus the first enabled row) and the menu's fallback role accurately.

Verification: DropdownMenu, DropdownMenuSubMenu, and Toolbar suites passed (356 tests); targeted ESLint, Prettier, and repository pre-commit checks passed.

@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.

Thanks for the follow-up: the source comments now describe the pointer-lit row and the fallback. Approval still waits on an engineering owner deciding the direction: the current MoreMenu record (docs/specs/components/MoreMenu/MoreMenu.spec.md, AR1) says a pointer open focuses the menu container and the first ArrowDown moves to the first row, and the DropdownMenu record does not cover the root menu's pointer open. An engineering owner records that decision, and can approve amending AR1 in this pull request, by commenting /approve-spec <full head SHA>; the author may do so if they are an engineering owner. CI has not run on this head yet; a maintainer adds the ci:run label so it runs.

  • Miss: (non-blocking) MenuHeaderFooter.a11y.chromium.spec.ts line 115 keeps const menu = await openMenu(page), which line 138 no longer uses, so ESLint warns; await openMenu(page); is enough.
  • Non-blocking: a few changed comments in DropdownMenu.tsx (lines 26-29, 1158, 1494-1495 and 1780-1781) could be shorter or more exact; suggestions are inline.
Claims and files checked
  • Claim: a mouse or finger open of DropdownMenu or MoreMenu focuses the first enabled item: verified (DropdownMenu.tsx:1236, the updated tests, and a Chromium check of both components).
  • Claim: this matches keyboard opens and the menu-button pattern: verified for keyboard parity; it conflicts with the current MoreMenu record.
  • Claim: a row the pointer already reached keeps focus: verified (DropdownMenu.tsx:1229-1238, DropdownMenu.test.tsx:2719).
  • Claim: the menu container stays the fallback when no item can take focus: verified in code (DropdownMenu.tsx:1236-1237); no pointer-open test covers it.
  • Claim: pointer focus goes through the shared last-input path with no keyboard ring: verified (DropdownMenu.tsx:1160, DropdownMenu.test.tsx:2698, Chromium shows no :focus-visible).
  • Claim: the focused first row shows the existing focus/hover overlay and no new visual treatment: verified (DropdownMenuItem.tsx:72 unchanged).
  • Claim: the four focused suites pass with 383 tests: verified.
  • Claim: repository pre-commit checks pass: Prettier is clean; ESLint reports one new warning (MenuHeaderFooter.a11y.chromium.spec.ts:115).
  • Claim (Changeset): pointer-opened DropdownMenu focuses the first enabled item and keeps a reached row: verified; MoreMenu changes too.
  • File .changeset/dropdown-menu-pointer-focus.md: clear.
  • File packages/core/src/DropdownMenu/DropdownMenu.tsx: waits on the owner decision; comment suggestions only.
  • File packages/core/src/DropdownMenu/DropdownMenu.test.tsx: clear.
  • File packages/core/src/DropdownMenu/DropdownMenuSubMenu.test.tsx: clear.
  • File packages/core/src/DropdownMenu/__tests__/DropdownMenuAudit.a11y.chromium.spec.ts: clear.
  • File packages/core/src/DropdownMenu/__tests__/MenuHeaderFooter.a11y.chromium.spec.ts: one unused variable (non-blocking).
  • File packages/core/src/DropdownMenu/__tests__/MenuPress.a11y.chromium.spec.ts: clear.
  • File packages/core/src/MoreMenu/MoreMenu.test.tsx: asserts the new behavior, which waits on the owner decision.
  • File packages/core/src/Toolbar/Toolbar.test.tsx: clear.

Automated review (maintainer link)

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 13, 2026
@cixzhang
cixzhang marked this pull request as draft November 13, 2026 18:19
@cixzhang
cixzhang marked this pull request as ready for review November 13, 2026 18:20
@cixzhang cixzhang removed the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 13, 2026

@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.

Thanks for the cleanup: the unused test binding is gone and the focused-menu suites pass on this head. Approval still waits on an engineering owner deciding the direction: the current MoreMenu record (docs/specs/components/MoreMenu/MoreMenu.spec.md, AR1) says a pointer open focuses the menu container and the first ArrowDown moves to the first row, and the DropdownMenu record does not cover the root menu's pointer open, so that record needs updating for this intentional change. An engineering owner records the decision, and can approve amending AR1 in this pull request, by commenting /approve-spec <full head SHA>; the author may do so if they are an engineering owner. CI has not run on this head yet; a maintainer adds the ci:run label so it runs.

  • Non-blocking: the comment on focusFollowsLastInput (DropdownMenu.tsx lines 1157-1158) describes the open effect's row preservation rather than the option, and two other changed comments can be shorter or keep their reason; suggestions are inline.
Claims and files checked
  • Claim: a mouse or finger open of DropdownMenu or MoreMenu focuses the first enabled item: verified (DropdownMenu.tsx:1235, the updated tests, and a Chromium check of both components).
  • Claim: this matches keyboard opens and the menu-button pattern: verified for keyboard parity; it conflicts with the current MoreMenu record.
  • Claim: a row the pointer already reached keeps focus: verified (DropdownMenu.tsx:1228-1235, DropdownMenu.test.tsx:2719).
  • Claim: the menu stays the fallback when no item can take focus: verified by reading (DropdownMenu.tsx:1235-1236); no test covers it.
  • Claim: pointer focus uses the shared last-input path and draws no keyboard ring: verified (DropdownMenu.tsx:1159, DropdownMenu.test.tsx:2698, Chromium).
  • Claim: the focused first row shows the existing focus/hover overlay, with no new visual treatment: verified (DropdownMenuItem.tsx:72, Chromium).
  • Claim: the four focused suites pass (383 tests): verified on this head.
  • Claim: repository pre-commit checks pass: ESLint and Prettier verified clean on the changed files.
  • Changeset: a core patch saying pointer-opened menus focus the first enabled item and keep a pointer-reached row: verified.
  • Files: DropdownMenu.tsx (comment suggestions only), DropdownMenu.test.tsx, DropdownMenuSubMenu.test.tsx, MoreMenu.test.tsx (waits on the MoreMenu decision), Toolbar.test.tsx, the three Chromium specs and the Changeset: clear.

Automated review (maintainer link)

@bezabyte

Copy link
Copy Markdown
Contributor Author

Addressed the optional documentation notes in d538487: clarified that focusFollowsLastInput controls pointer focus indication, documented the detail-0 keyboard/assistive-technology click path, and shortened the top-level focus summary.

Targeted ESLint and Prettier pass; the existing focused DropdownMenu/SubMenu/Toolbar suite remains 356/356. The engineering-owner MoreMenu/DropdownMenu contract and ci:run remain maintainer gates.

@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.

Thanks for adopting the comment suggestions: the three rewritten comments read well, and the focused menu suites pass on this head. Approval still waits on an engineering owner deciding whether a pointer open should focus the first enabled row (so the first ArrowDown moves to the second row): the current MoreMenu record (docs/specs/components/MoreMenu/MoreMenu.spec.md, AR1) says a pointer open focuses the menu container and the first ArrowDown moves to the first row, and the DropdownMenu record does not cover the root menu's pointer open, so that record needs updating for this intentional change. An engineering owner records the decision, and can approve amending AR1 in this pull request, by commenting /approve-spec <full head SHA>; the author may do so if they are an engineering owner. CI has not run on this head yet; a maintainer adds the ci:run label so it runs.

  • Non-blocking: two comments in DropdownMenu.tsx can be tightened (lines 1207-1213 say twice that a reached row keeps focus, and lines 1815-1817 still call the menu the pointer-open focus target); suggestions are inline.
Claims and files checked
  • Claim: a mouse or finger open of DropdownMenu or MoreMenu focuses the first enabled item: verified (DropdownMenu.tsx:1232, the updated tests, and a Chromium check of both components).
  • Claim: this matches keyboard opens and the menu-button pattern: verified for keyboard parity; it conflicts with the current MoreMenu record.
  • Claim: a row the pointer already reached keeps focus: verified (DropdownMenu.tsx:1225-1233, DropdownMenu.test.tsx:2719).
  • Claim: the menu stays the fallback when no item can take focus: verified by reading (DropdownMenu.tsx:1232-1233); no test covers it.
  • Claim: pointer focus uses the shared last-input path and draws no keyboard ring: verified (DropdownMenu.tsx:1156, DropdownMenu.test.tsx:2698, Chromium).
  • Claim: the focused first row shows the existing focus/hover overlay, with no new visual treatment: verified (DropdownMenuItem.tsx:72, Chromium).
  • Claim: the four focused suites pass (383 tests): verified on this head.
  • Claim: repository pre-commit checks pass: ESLint and Prettier verified clean on the changed files.
  • Changeset: a core patch saying pointer-opened menus focus the first enabled item and keep a pointer-reached row: verified.
  • Files: DropdownMenu.tsx (comment suggestions only), DropdownMenu.test.tsx, DropdownMenuSubMenu.test.tsx, MoreMenu.test.tsx (waits on the MoreMenu decision), Toolbar.test.tsx, the three Chromium specs and the Changeset: clear.

Automated review (maintainer link)

@bezabyte

Copy link
Copy Markdown
Contributor Author

Follow-up pushed in 54b770c: tightened the open-focus comment so it describes the pointer-reached-row behavior once, and clarified that the menu's focus ring is the no-row fallback case. The focused DropdownMenu/SubMenu/Toolbar suite remains 356/356; lint, formatting, and repository pre-commit checks pass. The engineering-owner focus-contract decision and ci:run remain the only gates.

@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.

Thanks for the follow-up: the tightened comments read well, and the focused menu suites pass on this head.

Approval still waits on an engineering owner deciding whether a pointer open should focus the first enabled row, which moves the first ArrowDown to the second row. The current MoreMenu record (docs/specs/components/MoreMenu/MoreMenu.spec.md, AR1) says a pointer open focuses the menu container and the first ArrowDown moves to the first row, and the DropdownMenu record does not cover the root menu's pointer open, so those records need updating for this intentional change. An engineering owner records the decision, and can approve amending the records in this pull request, by commenting /approve-spec <full head SHA>; the author may do so if they are an engineering owner.

Blocking:

  • Miss: the changeset (.changeset/dropdown-menu-pointer-focus.md, line 5) and the description say every pointer-opened DropdownMenu and MoreMenu now focuses the first enabled item, but with presentation="bottom-sheet" nothing changes and a pointer open leaves focus on the sheet panel in Chromium (DropdownMenu.tsx lines 683-686 move focus to the first action only after a keyboard open), so narrow both to the popover, for example "Pointer-opened DropdownMenu and MoreMenu popovers now focus the first enabled row; a row the pointer already reached keeps focus."
Claims and files checked
  • Claim: a pointer open of DropdownMenu or MoreMenu focuses the first enabled item: verified for the anchored popover (DropdownMenu.tsx:1221-1229, unit tests and a Chromium check); false for the bottom-sheet presentation (DropdownMenu.tsx:683-686).
  • Claim: this matches keyboard opens: verified (keyboard-open renders are identical on base and head).
  • Claim: a row the pointer already reached keeps focus: verified (DropdownMenu.tsx:1221-1226; the test that lights Duplicate before the open frame).
  • Claim: the menu container is the fallback when no row can take focus: verified (DropdownMenu.tsx:1227-1228; useListFocus.ts:624-632).
  • Claim: pointer focus goes through the shared last-input path, so no keyboard ring shows: verified (DropdownMenu.tsx:1156, useListFocus.ts:597-598; in Chromium the row is not focus-visible).
  • Claim: the focused first row shows its existing focus and hover overlay, with no new visual treatment: verified (Chromium renders).
  • Claim: the focused suites pass with 383 tests: verified (383 passed).
  • Claim: repository pre-commit checks pass: formatting and lint verified on the changed files; the hook itself was not run.
  • Claim: the changeset is .changeset/dropdown-menu-pointer-focus.md: verified.
  • Changeset: pointer-opened DropdownMenu instances focus the first enabled item and keep a reached row: false in scope (blocking finding above).
  • .changeset/dropdown-menu-pointer-focus.md: finding (scope).
  • packages/core/src/DropdownMenu/DropdownMenu.tsx: waits on the owner decision; one stale comment at line 1179 (non-blocking).
  • packages/core/src/DropdownMenu/DropdownMenu.test.tsx: clear.
  • packages/core/src/DropdownMenu/DropdownMenuSubMenu.test.tsx: clear.
  • packages/core/src/DropdownMenu/__tests__/DropdownMenuAudit.a11y.chromium.spec.ts: clear.
  • packages/core/src/DropdownMenu/__tests__/MenuHeaderFooter.a11y.chromium.spec.ts: clear.
  • packages/core/src/DropdownMenu/__tests__/MenuPress.a11y.chromium.spec.ts: clear.
  • packages/core/src/MoreMenu/MoreMenu.test.tsx: waits on the owner decision (asserts the opposite of MoreMenu AR1).
  • packages/core/src/Toolbar/Toolbar.test.tsx: clear.

Review mode: full — reason: author-not-engowner

Automated review (maintainer link)

@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.

Approval waits on an engineering owner deciding whether a pointer open of DropdownMenu and MoreMenu popovers should focus the first enabled row, which also moves the first ArrowDown to the second row and lights the first row while the opening mouse press is still held. The current MoreMenu record (docs/specs/components/MoreMenu/MoreMenu.spec.md, AR1) says a pointer open focuses the menu container, and the DropdownMenu record has no rule for the root menu's pointer open, so both need updating for this intentional change. An engineering owner records the decision, and can approve amending the records in this pull request, by commenting /approve-spec <full head SHA>; the author may do so if they are an engineering owner. No code change is required now: the changeset scope is fixed, the focused menu suites pass, and CI runs once a maintainer adds the ci:run label.

  • Optional: the comment above isMountedOpenRef in DropdownMenu.tsx still says later opens follow "the modality rules above", which this change removed.
Claims and files checked

Review mode: full; reason: author-not-engowner

  • Claim: a pointer open of a DropdownMenu or MoreMenu popover focuses the first enabled item: verified (DropdownMenu.tsx:1221-1229, unit tests, Chromium).
  • Claim: this matches keyboard opens and the menu-button pattern: verified for the focus target (keyboard-open renders are identical on base and head).
  • Claim: a row the pointer already reached keeps focus: verified (DropdownMenu.tsx:1222-1227, the test that lights Duplicate before the open frame).
  • Claim: the menu container is the fallback when no item can take focus: verified (DropdownMenu.tsx:1227-1228).
  • Claim: only the anchored popover changes and bottom sheets keep their focus behavior: verified (the sheet's open-focus code at DropdownMenu.tsx:683-686 is unchanged).
  • Claim: pointer focus goes through the shared last-input path, so no keyboard ring shows: verified (DropdownMenu.tsx:1156; in Chromium the row is not focus-visible).
  • Claim: the focused first row shows its existing focus and hover overlay, with no new visual treatment: verified (Chromium renders).
  • Claim: the focused suites pass with 383 tests: verified (383 passed).
  • Claim: repository pre-commit checks pass: formatting and lint verified on the changed files; the hook itself was not run.
  • Claim: the changeset file and the follow-up comment-cleanup commit exist: verified.
  • Changeset: pointer-opened DropdownMenu and MoreMenu popovers focus the first enabled item and keep a pointer-reached row, while bottom sheets keep their behavior: verified.
  • .changeset/dropdown-menu-pointer-focus.md: clear.
  • packages/core/src/DropdownMenu/DropdownMenu.tsx: waits on the owner decision; one stale comment above isMountedOpenRef (non-blocking).
  • packages/core/src/DropdownMenu/DropdownMenu.test.tsx: clear.
  • packages/core/src/DropdownMenu/DropdownMenuSubMenu.test.tsx: clear.
  • packages/core/src/DropdownMenu/__tests__/DropdownMenuAudit.a11y.chromium.spec.ts: clear.
  • packages/core/src/DropdownMenu/__tests__/MenuHeaderFooter.a11y.chromium.spec.ts: clear.
  • packages/core/src/DropdownMenu/__tests__/MenuPress.a11y.chromium.spec.ts: clear.
  • packages/core/src/MoreMenu/MoreMenu.test.tsx: waits on the owner decision (asserts the opposite of the MoreMenu record's AR1).
  • packages/core/src/Toolbar/Toolbar.test.tsx: clear.

Automated review (maintainer link)

active !== list &&
list?.contains(active) === true;
if (!isRowLit && (isPointerOpen || !focusEnd())) {
if (!isRowLit && !focusEnd()) {

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.

For the owner decision: while the mouse press that opened the menu is still held on the trigger, this frame now focuses the first row. In Chromium, Edit is focused and tinted 400 ms into the hold; on the base the menu container held focus and nothing was lit until the pointer reached a row. useMenuPress FR2 (docs/specs/components/DropdownMenu/modules/useMenuPress.spec.md) keeps nothing highlighted outside the menu during a held press, so the record amendment should say whether the opening press counts. If it does, the first-row focus has to wait for the release.

@cixzhang

Copy link
Copy Markdown
Contributor

(Posted by Cindy's agent.) Hi @bezabyte, this now conflicts with main in one file, packages/core/src/DropdownMenu/__tests__/DropdownMenuAudit.a11y.chromium.spec.ts, after #12343 changed how that audit captures geometry (it now waits for its frame samples to settle). Could you merge main into your branch (a merge, not a rebase) and keep both changes? If you'd rather we do it, say so here; edits by maintainers are enabled, so we can push the merge commit to your branch.

This branch was successfully deployed

1 active deployment
Preview — 7aa8df49 Deployed Nov 14, 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. community Authored by a community contributor (not on the eng/design team) lane:1 Astryx fix-loop lane 1 owns this needs:code-review High-risk change (new package/component/API) — needs human code review before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] DropdownMenu, MoreMenu: a mouse open focuses the menu container instead of the first item

3 participants