Skip to content

if submenu not same as default, the top-menu to rendered #2

@nathandunn

Description

@nathandunn

If I have two menus:

[A] B C
[1] 2 3

and [A] is selected with default [1]

If I select [2] it should be:

[A] B C
1 [2] 3

But instead [A] is not highlighted.

Using this type of notation:
<nav:render group="main-menu" />
<nav:renderSubItems group="main-menu"/>

(If I used <nav:render group="main-menu" submenu="true"/> it shows all of them . . . .not ideal)

To fix in NavigationTagLibrary.groovy I added an index:

// in eachItem (subItem is probably correct, but probably doesn't handle multiple levels):

        iterateItems(items, var, body, attrs.params, activePath, 0)


protected iterateItems = { items, var, body, linkParams, activePath, index = -1 ->

. . .

       if (index>=0) {
                data.active = pathIsActive(item.path[index], activePath[index])
            }
            else{
                data.active = pathIsActive(item.path, activePath)
            }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions