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 摘要。