adenvt / laravel-coreui-vue

Boilerplate for Single Page Application, powered by Laravel, CoreUI, Vue
https://packagist.org/packages/adenvt/laravel-coreui-vue
MIT License
79 stars 26 forks source link

Sidebar item child not expand after reload page #27

Closed a21ns1g4ts closed 5 years ago

a21ns1g4ts commented 5 years ago

When the user click in page or reload the sidebar item cannot stayed expand image After reload : image

adenvt commented 5 years ago

Can you give me your _nav.js?

a21ns1g4ts commented 5 years ago

Can you give me your _nav.js?

export default {
  items: [
    {
      name : 'Painel',
      url  : '/painel',
      icon : 'icon-speedometer',
      badge: {
        variant: 'primary',
        text   : 'administração',
      },
    },
    {
      title  : true,
      name   : 'Módulos',
      class  : '',
      wrapper: {
        element   : '',
        attributes: {},
      },
    },
    {
      name    : 'Contribuinte',
      url     : '/painel/contribuinte',
      icon    : 'icon-people',
      children: [
        {
          name: 'Criar',
          url : '/painel/contribuinte/criar',
          icon: 'icon-user-follow',
        },
        {
          name: 'Listar',
          url : '/painel/contribuinte/listar',
          icon: 'icon-list',
        },
      ],
    },
    {
      name    : 'Configurações',
      url     : '/painel/configuracoes/index',
      icon    : 'icon-wrench',
      children: [
        {
          name: 'Listar',
          url : '/painel/configuracoes/index',
          icon: 'icon-grid',
        },
        {
          name    : 'Orgao',
          url     : '/painel/configuracoes/orgao/index',
          icon    : 'fa fa-bullseye',
          children: [
            {
              name: 'Criar',
              url : '/painel/configuracoes/orgao/criar',
              icon: 'icon-plus',
            },
            {
              name: 'Listar',
              url : '/painel/configuracoes/orgao/listar',
              icon: 'icon-list',
            },
          ],
        },
        {
          name    : 'Convênio',
          url     : '/painel/configuracoes/convenio/listar',
          icon    : 'icon-wrench',
          children: [
            {
              name: 'Criar',
              url : '/painel/configuracoes/convenio/criar',
              icon: 'icon-plus',
            },
            {
              name: 'Listar',
              url : '/painel/configuracoes/convenio/listar',
              icon: 'icon-list',
            },
          ],
        },
      ],
    },
  ],
}
adenvt commented 5 years ago

Sidebar Dropdown expand automatically using router-link active state when component created.

At Configurações, url is /painel/configuracoes/index, when you visited /painel/configuracoes/convenio/criar, router-link not detected it as active because /painel/configuracoes/convenio/criar not contains /painel/configuracoes/index.

Solution, change /painel/configuracoes/index to /painel/configuracoes. and add redirect /painel/configuracoes to /painel/configuracoes/index in router/index.js

a21ns1g4ts commented 5 years ago

Thank this solved my problem.