angular / angular/components

bug(ngMenu): onSelect does not emit values

未关闭
#32,435 2 条评论 3 个 reaction 已指派 1 人 已被 @ok7sai 认领 在 GitHub 查看
area: material/menu P3
主要语言
TypeScript
星标
25k
派生
6.8k
平均合并
1 天 8 小时
30 天内合并 PR
91

描述

### 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

I tried using Angular Aria's ngMenu based on the [setup from the docs](https://angular.dev/guide/aria/menu#menu-with-trigger) but it doesn't seem to work. The `onSelect` output doesn't emit the selected value.

On the other note, the docs are also not explicitly stating how to actually use any of the components - I had to read the [tests](https://github.com/angular/components/blob/2c0ba8d1498512b1192ccc79476f123a03658a72/src/aria/menu/menu.spec.ts#L947) and the [source code](https://github.com/angular/components/blob/2c0ba8d1498512b1192ccc79476f123a03658a72/src/aria/menu/menu.ts#L221) to be sure what's expected (I know about the API button at the top of the docs page that lists the `onSelect`, but it's not obvious that this is intended way). It would be useful to see a showcase on how to use values from these components.

### Reproduction

StackBlitz link: https://stackblitz.com/edit/stackblitz-starters-whsmfbqs?file=src%2Fmenu-test%2Fmenu-test.html
Steps to reproduce:
1. The relevant implementation is in `src/menu-test/menu-test.html` & `src/menu-test/menu-test.ts`
2. After the menu item is selected (click or enter key) it should be logged into console
3. There's no log in the console. The onSelect didn't emit a value.

### Expected Behavior

The onSelect should emit a value and the value should be a logged in the console.

### Actual Behavior

The onSelect didn't emit a value. There's no log in the console.

### Environment

- Angular: latest ^21.0.1
- ~CDK/Material~ Aria: ^21.0.1
- Browser(s): Chrome
- Operating System (e.g. Windows, macOS, Ubuntu): macOS

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。