Skip to content

bug(cdk-menu): navigation is not triggered on SPACE and ENTER #25584

Closed
@ghost

Description

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

Navigation does not occur on pressing Enter or Space when <a> element has cdkMenuItem.
<a routerLink="/" fragment="menu-1" cdkMenuItem>item 1</a>

I think the issue is caused by this line https://github.com/angular/components/blob/main/src/cdk/menu/menu-item.ts#L200

Reproduction

Steps to reproduce:

  1. https://stackblitz.com/edit/components-issue-nwpike?file=src%2Fapp%2Fexample-component.html
  2. Use keyboard to focus a link at the top and press Enter to navigate. Nothing happens.
  3. Use keyboard to focus a link at the bottom and press Enter to navigate. Navigation occurs.

Expected Behavior

Navigation should work with keyboard

Actual Behavior

Navigation does not work with keyboard

Environment

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

Metadata

Metadata

Assignees

Labels

P2The issue is important to a large percentage of users, with a workaroundarea: cdk/menu

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions