feat(aria/menu): Add possibility to create a shared menu component from aria/menu
维护者通常 1 天内回复
@ok7sai 已经在做这个了。
开始于 2026年4月1日。
评估
这个 Issue 还没有评估数据。
描述
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
- 主要语言
- TypeScript
- 星标
- 25k
- 派生
- 6.8k
- 平均合并
- 1 天 5 小时
- 30 天内合并 PR
- 67
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
angular/components 的其他 Issue
-
area: aria/combobox gemini-triaged
难度 2/5 1-3 小时 新手友好度 78/100
angular/components#33973 ·
维护者通常 1 天内回复
-
bug(aria/combobox): ComboboxPopup throws NG0950 when destroyed before its first change detection未关闭area: aria/combobox gemini-triaged
难度 2/5 1-3 小时 新手友好度 78/100
angular/components#33972 ·
维护者通常 1 天内回复
-
bug(material/sort): hover hint arrow on an unsorted header shows the active sort direction, not the resulting direction after click.可能已有人在做 @lekhmanrus 于 11 天前认领。 未关闭area: material/sort P3
难度 2/5 1-3 小时 新手友好度 70/100
angular/components#33933 ·
维护者通常 1 天内回复
-
bug(mat-date-picker): month shown twice in date picker可能已有人在做 @PreethiPantangi 于 29 天前认领。 未关闭area: material/datepicker P4
难度 2/5 1-3 小时 新手友好度 72/100
angular/components#33763 · 2 条评论 · 3 个 reaction ·
维护者通常 1 天内回复
-
Bug in table.scss footer cell height: unset instead of footer row height unset可能已有人在做 @minwookshin 于 15 天前认领。 未关闭area: material/table P4
难度 1/5 1 小时以内 新手友好度 88/100
angular/components#33709 · 1 条评论 ·
维护者通常 1 天内回复
查看 angular/components 的全部 Issue
相似的 Issue
-
e2e-failure ready-to-code
难度 2/5 1-3 小时 新手友好度 68/100
redhat-developer/rhdh-plugin-export-overlays#4460 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 77/100
维护者通常 1 天内回复
-
docs(api): openapi.yaml still documents gif-tools optimize colors as 2-256 instead of 2, 4, 16, 256未关闭area: backend documentation priority: low
难度 2/5 1-3 小时 新手友好度 84/100
snapotter-hq/SnapOtter#2919 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 77/100
obsidianmd/pele#39 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复