feat(aria/menu): Add possibility to create a shared menu component from aria/menu
Maintainer thường phản hồi trong vòng 1 ngày
@ok7sai đang làm issue này rồi.
Từ ngày 1/4/2026.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
Feature Description
When building a menu using aria/menu you have to have the following structure:
- an for cdkConnectedOverlay
- a container element with ngMenu
- another for ngMenuContent
- only then the actual ngMenuItem elements
This results in 4 structural levels that need to be repeated every time you need a new menu.
I attempted to create a shared menu component (similar to Angular Material’s MatMenu) in order to reduce this complexity to 2 levels and enable an API like:
<button appMenuTrigger #appMenuTrigger="appMenuTrigger" [appMenu]="appMenu.formatMenu()">
Open Menu
</button>
<app-menu #appMenu [appMenuTrigger]="appMenuTrigger">
<app-menu-item value="Mark as read">
<span class="icon material-symbols-outlined" aria-hidden="true">mark_email_read</span>
<span class="label">Mark as read</span>
</app-menu-item>
<app-menu-item value="Snooze">
<span class="icon material-symbols-outlined" aria-hidden="true">snooze</span>
<span class="label">Snooze</span>
</app-menu-item>
</app-menu>
Internally, app-menu wraps Menu and MenuContent:
@Component({
selector: 'app-menu',
imports: [OverlayModule, Menu, MenuContent],
template: `
<ng-template
[cdkConnectedOverlayOpen]="appMenuTrigger().menuTrigger.expanded()"
[cdkConnectedOverlay]="{ origin: appMenuTrigger().nativeElement, usePopover: 'inline' }"
[cdkConnectedOverlayPositions]="overlayPositions"
cdkAttachPopoverAsChild>
<div ngMenu class="menu" #formatMenu="ngMenu">
<ng-template ngMenuContent>
<ng-content />
</ng-template>
</div>
</ng-template>
`
})
export class AppMenu {
appMenuTrigger = input.required<AppMenuTrigger>();
formatMenu = viewChild<Menu<string>>('formatMenu');
overlayPositions: ConnectedPosition[] = [{originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top', offsetY: 4}];
}
and menu items are wrapped like this:
@Component({
selector: 'app-menu-item',
template: '<ng-content />',
hostDirectives: [{ directive: MenuItem, inputs: ['value: value'] }]
})
export class AppMenuItem {}
Problem
With this approach, accessibility breaks (keyboard navigation no longer works correctly). This seems to happen because Menu cannot properly register MenuItem children when they are content projected.
Proposed enhancement
Expose a public API on Menu that allows the menu to "refresh" in order to register the items when they are content projected.
Use Case
No response
- Ngôn ngữ chính
- TypeScript
- Star
- 25k
- Fork
- 6.8k
- Merge trung bình
- 1 ngày 5 giờ
- Pull request đã merge (30 ngày)
- 67
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của angular/components
-
bug(material/sort): hover hint arrow on an unsorted header shows the active sort direction, not the resulting direction after click.Có thể đã có người làm @lekhmanrus đã nhận 11 ngày trước. Đang mởarea: material/sort P3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
angular/components#33933 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug(mat-date-picker): month shown twice in date pickerCó thể đã có người làm @PreethiPantangi đã nhận 28 ngày trước. Đang mởarea: material/datepicker P4
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
angular/components#33763 · 2 bình luận · 3 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug in table.scss footer cell height: unset instead of footer row height unsetCó thể đã có người làm @minwookshin đã nhận 15 ngày trước. Đang mởarea: material/table P4
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
angular/components#33709 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
docs-bug(Table): Add example with `rowspan`Có thể đã có người làm @BHUVANSH855 đã nhận 96 ngày trước. Đang mởarea: material/table docs P4
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
angular/components#33455 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug(date-adapter): Misleading JSDoc for createDate returns typeCó thể đã có người làm @BHUVANSH855 đã nhận 145 ngày trước. Đang mởarea: material/core P3
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
angular/components#33059 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của angular/components
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
ccch1mneyyy/dsh-TUI#1631 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
MiniMax-AI/minimax-code#507 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Transient OAuth login failure persists in getLoginStatus and masks active account in dashboardCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởaccount-pool bug gui
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
lidge-jun/opencodex#7378 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Admin search throws for permissions added through Admin.generalIndexItems('permissions', ...)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày