nebular icon indicating copy to clipboard operation
nebular copied to clipboard

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

Open mehmetalpsumer opened this issue 6 years ago • 6 comments

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

mehmetalpsumer avatar Feb 01 '19 17:02 mehmetalpsumer