Laravel-adminlte: Submenu "active checking" does not work when using "route"

Created on 7 Sep 2017  路  9Comments  路  Source: jeroennoten/Laravel-AdminLTE

When I set the "route" option in the submenu items, the menu is not being shown as active on those pages.

It works when i set the route of an item without a submenu though.

example:

[
   'text' => 'Item',
   'route' => 'item-route'
]

^^ This will work, and the item will be active when viewing the page.

[
   'text' => 'Parent',
   'submenu' => [
      [
         'text' => 'Child',
         'route' => 'item-child'
      ]
   ]
]

^^ This will not work. When viewing the child page, the menu is not expanded and the page is not shown as active.

bug

All 9 comments

Thanks for the bug report. I am looking for a way to fix this. A PR that fixes this issue is more than welcome. I already made up a failing test case:

    public function testSubmenuActiveWithRoute()
    {
        $builder = $this->makeMenuBuilder('http://example.com/about');
        $this->getRouteCollection()->add(new Route('GET', 'about', ['as' => 'pages.about']));

        $builder->add(['submenu' => [['text' => 'About', 'route' => 'pages.about']]]);

        $this->assertTrue($builder->menu[0]['active']);
    }

Is this test case for phpunit or dusk? The test case won't run because none of those methods are part of the test object. Am I missing something here?

In order to run the test suite, clone this repository and run phpunit. You should indeed not run these test within your own project.

I fixed it. Issue was in the HrefFilter. It wasn't interating through the submenus to generate the hrefs from routes before the active filter was applied. Also fixed an issue in the active filter that caused all sub items to become active when the paths were like: /company, /company/create - When going to create, both /company and /company/create were lit up. This was at any time, not just when routes were used. Simplified active filter code.

PR on the way.

Disregard the second issue, the HrefFilter fixes the original problem.

I will create another issue for the multiple active problem.

How can I integrate jeroennoten/Laravel-AdminLTE with Zizaco/entrust?

I am interested in integrating jeroennoten/Laravel-AdminLTE with Zizaco/entrust, for the management of roles and persmisos.

I have used both but I have to build an independent menu assigning the roles and permissions.

How can I do this without affecting component integrity?

Hello, whats news about this issue?
I have the same problem, can you help me ?

@roblesterjr04 have your PR added?
I am interested in this issue.

PR was merged.

Was this page helpful?
0 / 5 - 0 ratings