Skip to content

fix(aria/menu): close open submenu when typeahead moves focus in menubar#33491

Open
Daherkarim wants to merge 1 commit into
angular:mainfrom
Daherkarim:fix/menubar-typeahead-close-submenu
Open

fix(aria/menu): close open submenu when typeahead moves focus in menubar#33491
Daherkarim wants to merge 1 commit into
angular:mainfrom
Daherkarim:fix/menubar-typeahead-close-submenu

Conversation

@Daherkarim

Copy link
Copy Markdown
Contributor

Summary

When a menubar item was clicked to open its submenu and the user then used typeahead to move focus to another menubar item, the new item's submenu opened while the previously clicked item remained expanded, leaving two submenus open at the same time.

This change makes typeahead navigation in the menubar close the previously expanded item and move the open state to the newly focused item, matching the behavior of arrow key and pointer navigation. If no submenu was open, or typeahead does not move focus (no match, or the match is the already-active item), the expanded state is left untouched.

The duplicated close-and-reopen logic in goto, next and prev was consolidated into a shared _switchExpandedItem helper, which typeahead now also uses.

Changes

  • src/aria/private/menu/menu.ts: close the previously expanded menubar item when typeahead moves focus; consolidate the logic shared with goto/next/prev.
  • src/aria/menu/menu.spec.ts: unit tests covering typeahead with an open submenu, with no open submenu, and when focus does not move.
  • src/components-examples/aria/menubar + src/dev-app/aria-menubar: a typeahead example for manual testing in the dev app.

Testing

  • bazel test //src/aria/menu:unit_tests passes (Chromium and Firefox).

Previously, when a menubar item was clicked to open its submenu and the
user then used typeahead to move focus to another menubar item, the new
item's submenu opened while the previously clicked item remained
expanded, leaving two submenus open at the same time.

Typeahead navigation in the menubar now closes the previously expanded
item and moves the open state to the newly focused item, matching the
behavior of arrow key and pointer navigation. If no submenu was open, or
typeahead does not move focus, the expanded state is left untouched.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant