akveo / akveo/nebular

NbMenuService.onItemClick() calls even if not clicked after the first time

未关闭
#1,284 6 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
bug module:components P2: important quality
主要语言
TypeScript
星标
8.1k
派生
1.5k
PR 合并指标
30 天内没有已合并 PR

描述

### Issue type

* [x] bug report
* [ ] feature request
* [ ] question about the decisions made in the repository

### Issue description

**Current behavior:**
"NbMenuService" component's onItemClick event is called even though I don't click to it, and unsubscribe on destroy.

**Expected behavior:**
```NbMenuService.onItemClick()``` only called on click.

**Steps to reproduce:**

I added this to header component in ngx-admin, and on logout route I call ```auth.logout()```. I log in and redirect to dashboard. Then if I click logout, it redirects me to login page, everything works proper until now. But after logging out, if I login and redirect to dashboard again, it will call logout directly.

**Related code:**

```
test: Subscription;
ngOnInit() {
this.test = this.menuService.onItemClick()
.pipe(
filter(({ tag }) => tag === 'my-context-menu'),
map(({ item: { title } }) => title),
).subscribe(title => {
if (title == 'Logout') {
this.router.navigate(['/auth/logout']);
}
}
);
}

ngOnDestroy() {
test.unsubscribe();
}
```

### Other information:

Firefox
Windows 10
Angular 6
Nebular 2.0.0-rc.9

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

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