Skip to content

bug(cdk/menu): not possible to update active focus item #31370

Open
@chintankavathia

Description

@chintankavathia

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

CdkMenu uses FocusManager to navigate through menu items howerever focuskeymanager is not exposed to public to programatically set different item as active one.

Although cdkMenuItem has focus method it only allows to focus specific menu item and doesn't set the active item in focusmanager accordingly.

Reproduction

StackBlitz link: https://stackblitz.com/edit/4a2okv3p?file=src%2Fexample%2Fcdk-menu-inline-example.ts
Steps to reproduce:

  1. Go to given StackBlitz link
  2. Observe 2nd item is focused
  3. Hit Arrow Down
  4. Observe focus shifts to first item on the list instead of 3rd

Expected Behavior

focus should go to next item when pressing arrow down.

one possible solution is to provide api setActiveMenuItem on cdkmenu

Actual Behavior

focus resets back to first item.

Environment

  • Angular: 20
  • CDK/Material: 20
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageThis issue needs to be triaged by the team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions