akveo / akveo/nebular

fix for responding to expand event on compacted menu item

未关闭
#2,582 0 条评论 0 个 reaction 已指派 1 人 已被 @katebatura 认领 在 GitHub 查看
主要语言
TypeScript
星标
8.1k
派生
1.5k
PR 合并指标
30 天内没有已合并 PR

描述

in the sidebar.component.ts there is a work-around to send an expand event from the menu to the sidebarService.
i would like to propose a better solution

here is the first solution that currently exists in the code
// TODO: this is more of a workaround, should be a better way to make components communicate to each other
onClick(event): void {
const menu = this.element.nativeElement.querySelector('nb-menu');

if (menu && menu.contains(event.target)) {
const link = this.getMenuLink(event.target);

if (link && link.nextElementSibling && link.nextElementSibling.classList.contains('menu-items')) {
this.sidebarService.expand(this.tag);
}
}
}

my solution is to do the following in ngOnInit

this.menuService.onSubmenuToggle()
.pipe(takeUntil(this.destroy$))
.subscribe((data: { tag: string; item: NbMenuItem }) => {
if (!data.tag || this.tag === data.tag) {
if (data.item.expanded) {
this.sidebarService.expand(data.tag);
}
}
});

this.menuService.onSubmenuToggle()
.pipe(takeUntil(this.destroy$))
.subscribe((data: { tag: string; item: NbMenuItem }) => {
if (!data.tag || this.tag === data.tag)
if (data.item.expanded) {
this.sidebarService.expand(data.tag);
}
});

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

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