NbMenuService.onItemClick() calls even if not clicked after the first time
See original GitHub issueIssue type
- 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 Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5
Top Results From Across the Web
NbMenuService.onItemClick() calls even if not clicked after ...
Current behavior: "NbMenuService" component's onItemClick event is called even though I don't click to it, and unsubscribe on destroy. Expected ...
Read more >How to get the Main menu click value in nebular (Not ...
menuService.onItemClick().subscribe((event) => { if (event.item.
Read more >nebular/theme/index.metadata.json
'chevron-left-outline' : 'chevron-right-outline'\" pack=\"nebular-essentials\"></nb-icon>\n </button>\n <button nbButton (click)=\"next.emit()\" ghost ...
Read more >CHANGELOG.md · Gitee 极速下载/Nebular - Gitee.com
menu: The NbMenuService not reply the last click event. To update: if you use the knowledge that the last click event is replied...
Read more >akveo/nebular release history - changelogs.md
menu: The NbMenuService not reply the last click event. To update: if you use the knowledge that the last click event is replied...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello! I have been trying to fix this issue when you implement the "onItemClick " event you should “unsubscribe”, the real problem of @mehmetalpsumer it’s a bad usage of ngOnDestroy method. Check out if the class is implemented in your class like:
export class ExampleComponent implements OnInit, OnDestroy {}
And you should calltest.unsubscribe();
as a global variable usingthis. test.unsubscribe();
.It works for me. Have a nice day
@DiegoDominguezSTX you’r right we need to unsubscribe nbMenuService in ngOnDestroy() method . thank you so much @DiegoDominguezSTX