NbMenuService.onItemClick() calls even if not clicked after the first time
- Dominant language
- TypeScript
- Stars
- 8.1k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
### 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
Contributor guide
Assessment
This issue has not been assessed yet.