Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to compact sidebar on item click not working #82

Closed
hriverahdez opened this issue Nov 22, 2017 · 5 comments
Closed

Trying to compact sidebar on item click not working #82

hriverahdez opened this issue Nov 22, 2017 · 5 comments

Comments

@hriverahdez
Copy link

I am using NbMenuService's onItemSelect method and subscribing to it. Then when an Item is clicked I am calling NbSidebarService's toggle function and passing in the sidebar's tag. It's not working. Oddly on the ngx-admin demo, the toggle menu icon on the header has a click handler that executes the same code to toggle the sidebar which I am now using and it works there.
This is the code I'm using. It lies on ngOnInit() of a component that encompases the whole app layout and that includes the sidebar on its template. Any idea why it's not working?

this.menuService.onItemSelect() .subscribe((event: {tag: string, item: any}) => { this.sidebarService.toggle(true, 'menu-sidebar'); });

@nnixaa
Copy link
Collaborator

nnixaa commented Dec 19, 2017

Hi @hriverahdez, could you please provide a complete reproducible example so that we can look into.

@hriverahdez
Copy link
Author

Hi @nnixaa, I've set up a sample project at https://github.com/hriverahdez/sidebar-example.git in which I followed part of the installation process of nebular. Adding a custom theme configuration in the scss and using some of the styles available in the ngx-admin's header component (just cosmetics)
Relevant code is at app.component.ts ngOnInit where I'm subscribing to menu item clicks.

@nnixaa
Copy link
Collaborator

nnixaa commented Dec 19, 2017

Okay, I see the issue. The problem lies here https://github.com/akveo/nebular/blob/master/src/framework/theme/components/sidebar/sidebar.component.ts#L245 so that it expands the sidebar right after you collapse it :/
As a temporary workaround, I'd suggest wrapping your toggle statement with setTimeout so that the toggle part is executed after the onClick on the sidebar.
setTimeout(() => this.sidebarService.toggle(false, 'menu-sidebar'));
We probably have to rethink that onClick feature of the sidebar.

@nnixaa nnixaa added bug and removed needs info labels Dec 19, 2017
@hriverahdez
Copy link
Author

The timeout workaround might do the trick. Thanks. I'll leave it to you to close the issue since is not yet resolved. Might be nice to get an update on this matter, #23 is presenting a similar situation where the this.expand() line is causing the problem.

@nnixaa
Copy link
Collaborator

nnixaa commented Dec 20, 2017

@hriverahdez let's close this one and track the issue in #23 then.

@nnixaa nnixaa closed this as completed Dec 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants