Skip to content

bug(cdkMenu): cdkMenu keyboard navigation doesn't skip disabled options like mat-menu does #31102

@Cohaven

Description

@Cohaven

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 keyboard navigation doesn't skip disabled options like mat-menu does. cdkMenu loses menu item focus when navigating to a disabled menu item, while mat-menu focuses the next available menu item that is not disabled.

Reproduction

CDK behaviour: https://stackblitz.com/edit/jqrnmquv-y12cuztc?file=src%2Fexample%2Fcdk-menu-standalone-menu-example.html
Steps to reproduce:

  1. Open menu
  2. Press down arrow key - "Refresh" menu item is selected
  3. Press down arrow key again - "Help" menu item is selected and "Settings" is skipped because it is disabled
  4. Press up arrow key - no menu item is selected.
  5. Press up arrow key again - "Refresh" menu item is selected

From this point on, it takes two button presses to select a menu item before or after the disabled "Settings" menu item. This behaviour is even more buggy when the first item in the menu list is disabled.

Mat Menu behaviour: https://stackblitz.com/edit/6hkqcjif?file=src%2Fexample%2Fmenu-icons-example.html
Steps to reproduce:

  1. Open menu
  2. Press down arrow key - "Disable alerts" menu item is selected. For some reason, "Redial" gets skipped, so there could be another bug here, but it's not the behaviour that I wanted to focus on in this discussion.
  3. Press up arrow key - "Check voice mail" is skipped because it is disabled, and "Redial" is selected.

Expected Behavior

I would like the disabled menu items to be skipped completely in cdk like they are in mat-menu.

Actual Behavior

cdkMenu loses menu item focus when navigating to a disabled menu item

Environment

  • Angular: ^19.2.0
  • CDK/Material: ^19.2.0
  • 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