coreui / coreui-angular

CoreUI Components Library for Angular https://coreui.io/angular/docs/
https://coreui.io/angular/
MIT License
244 stars 145 forks source link

Sidebar Collapse all on click #159

Closed kernle27 closed 1 year ago

kernle27 commented 1 year ago

Hejoo,

A Question is this a Bug or did i somenthing wrong? If i Click in Sidebar on an Child he Complete Links are Collapse to "close" State. How can i avoid that ?

Hope you can help me.

Thanks

xidedix commented 1 year ago

@kernle27 I'm not sure what you mean by"Complete Links".

As far as understand c-sidebar-nav-group closes when you click on its child c-sidebar-nav-link. It works this way if the url prop of a group does not match the url prop of its active child, say:

// non matching url of Base - group closes always
export const navItems: INavData[] = [
  {
    name: 'Base',
    url: '/non-matching-url',
    iconComponent: { name: 'cil-puzzle' },
    children: [
      {
        name: 'Accordion',
        url: '/base/accordion'
      },
...
// matching url of Base - group should stay open
export const navItems: INavData[] = [
  {
    name: 'Base',
    url: '/base',
    iconComponent: { name: 'cil-puzzle' },
    children: [
      {
        name: 'Accordion',
        url: '/base/accordion'
      },
...
kernle27 commented 1 year ago

Hej @xidedix,

Thanks for your fast response. so what i can tell i have this settings like u see the Picture. And now if i click on an child navitem under a parent all childs collapses to the closed state. I also tryed without the slash and with the slashes all the same.

image

xidedix commented 1 year ago

@kernle27 cannot reproduce...

  1. what happens if you try an url with a starting slash like:
    • /admin
    • /admin/belegauswertung
export const navItems: INavData[] = [
  {
    name: 'Auswertungen',
    url: '/admin',
    iconComponent: { name: 'cilMenu' },
    children: [
      {
        name: 'Belegauswertung',
        url: '/admin/belegauswertung'
      },
      ...
  1. Is /admin at the first level of your sidebar-nav menu?
  2. What do you see at the address bar of your web browser for Belegauswertung? It should be http://localhost:4200/#/admin/belegauswertung or http://localhost:4200/admin/belegauswertung
  3. What's your version of @coreui/angular?
kernle27 commented 1 year ago

@xidedix i have an emty routing module before so the full url = dbonapp/admin/....

Did you think thats the Problem? Hope is possible in some way that i can keep this emty Route before

xidedix commented 1 year ago

@kernle27 so maybe you could try like this?

export const navItems: INavData[] = [
  {
    name: 'Auswertungen',
    url: '/dbonapp/admin',
    iconComponent: { name: 'cilMenu' },
    children: [
      {
        name: 'Belegauswertung',
        url: '/dbonapp/admin/belegauswertung'
      },
      ...
kernle27 commented 1 year ago

@xidedix you are great men 😉 it works!!! But now the sidebar after the login all childs are expanded .

xidedix commented 1 year ago

@kernle27 well, they are expanded, because they all match an active route... huh... 🤔

kernle27 commented 1 year ago

@xidedix well, make sense ;) in this case i think i need to rethink my handling. we have different products... and the Backend give me the product from the user back.. according to that the (first emty) route will be active... looks like i need a different solution for handling the different products. any idea to make it better?

xidedix commented 1 year ago

@kernle27

<c-sidebar-nav
  [navItems]="navItems"
  dropdownMode="none">
</c-sidebar-nav>

We're considering a kind of patch to cover your use case.

kernle27 commented 1 year ago

Hej @xidedix , I have done it already i have a emty route with different urls after admin. Now it works like a charm... If this is a good solution is questionable.. but so far it works for me. I will give ur tip a chance and see what is working better.

Btw sorry for my bad english and thanks for your Help i appreciate it

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions