bug(cdkMenuItem): Pressing "Enter" on non-button and non-anchor elements reopens the menu unexpectedly. #30250
Labels
area: cdk/menu
P3
An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Description
When using the cdkMenuItem directive on non-button and non-anchor elements (e.g., <div> or <span>), pressing the "Enter" key causes the current menu to reopen unexpectedly. This issue affects accessibility and usability when creating custom menu components. Menu is properly closed on mouse click and pressing the "Spacebar" key.
Reproduction
StackBlitz link: https://stackblitz.com/edit/vsy7hsgs?file=src%2Fexample%2Fcdk-menu-menubar-example.html
Steps to reproduce:
Expected Behavior
The menu should not reopen or toggle when "Enter" is pressed on a cdkMenuItem element if no additional click or keyboard action is configured.
Actual Behavior
Pressing "Enter" on a cdkMenuItem element (e.g., <div>) causes the menu to reopen unexpectedly.
Environment
The text was updated successfully, but these errors were encountered: