feat(menu): remove hasAutoFocus, always focus first item on open (APG)#3438
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Looks reasonable but there's a build error preventing the preview site from building to test. |
|
Approving to unblock, but flagging before this lands: the |
d9bb858 to
e278396
Compare
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR No new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
APG menu-button: a menu must focus its first item when it opens. The
hasAutoFocus={false} escape hatch left menus keyboard-unreachable and
undismissable (the audit's menus-2 root cause in the Table context menu path).
Removed from DropdownMenu, ContextMenu, MoreMenu.
…e + ContextMenu tests
e278396 to
7342a97
Compare
Summary
Removes the
hasAutoFocusprop fromDropdownMenu,ContextMenu, andMoreMenu. Menus now always focus their first item on open — the correct APG menu-button behavior.Why
The
hasAutoFocus={false}escape hatch existed for showcase previews, but it violated APG and was the root cause of the audit'smenus-2finding: Table plugin context menus opened withhasAutoFocus={false}, so no item received focus, and the menu was unreachable by keyboard and undismissable via Escape (because the Escape handler sat on a menu element that never had focus). Other menu instances used the default (true) and were fine — the prop only existed to support a scenario that no longer applies (showcases now render into sandboxes that isolate focus).Breaking change
Consumers passing
hasAutoFocus={false}to aDropdownMenu,ContextMenu, orMoreMenuwill get a TypeScript error. The fix is to remove the prop — the menu will auto-focus as it should.Internal
usePopover({hasAutoFocus: false})calls (used by menus internally to prevent usePopover's generic first-focusable autofocus, since menus drive focus via their ownfocusFirst) are unchanged.What was updated
DropdownMenu.tsx: removed prop + madefocusFirst()unconditional.ContextMenu.tsx: same.MoreMenu.tsx: removed pass-through.tableContextMenu.tsx: removed thehasAutoFocus={false}passes that caused menus-2.hasAutoFocus={false}..doc.mjsfiles: removed prop documentation.DropdownMenu.test.tsx: removed the test asserting the oldhasAutoFocus={false}behavior.Verification
Typecheck + lint clean; 384 tests pass across DropdownMenu + ContextMenu + MoreMenu + the full Table suite (which exercises the table context menu). No regressions.