Skip to content

SidebarNavHelper.isActive should check child items for dropdowns #155

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

Closed
maxtacco opened this issue Jun 12, 2019 · 2 comments
Closed

SidebarNavHelper.isActive should check child items for dropdowns #155

maxtacco opened this issue Jun 12, 2019 · 2 comments

Comments

@maxtacco
Copy link

Hi,

I have a case when urls of child items do not start with the same path as parent's url. In this scenario item selection is not working as expected. So, is it possible to change SidebarNavHelper.isActive to something like this:

public isActive(router, item) {
    const url = item.url;
    if (this.itemType(item) === 'dropdown') {
      if (url === '' || url === '#') {
        return item.children.some((childItem: any) => router.isActive(childItem.url, true));
      } else {
        return router.isActive(url, false);
      }
    } else {
      return router.isActive(url, true);
    }
  }
@maxtacco
Copy link
Author

Recursive version should work in case you decide to have nested dropdowns at some point:

public isActive(router, item) {
    const url = item.url;
    if (this.itemType(item) === 'dropdown') {
      if (url === '' || url === '#') {
        return item.children.some((childItem: any) => this.isActive(router, childItem));
      } else {
        return router.isActive(url, false);
      }
    } else {
      return router.isActive(url, true);
    }
  }

@maxtacco
Copy link
Author

Sorry, realized this better belongs in @coreui/angular. Please see coreui/coreui-angular#67

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

1 participant