angular / angular/components

bug(ngMenu): onSelect does not emit values

Đang mở
#32,435 2 bình luận 3 reaction 1 người được giao Được @ok7sai nhận Xem trên GitHub
area: material/menu P3
Ngôn ngữ chính
TypeScript
Star
25k
Fork
6.8k
Merge trung bình
1 ngày 8 giờ
Pull request đã merge (30 ngày)
91

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.