Skip to content
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

Even selected Items don't change state #162

Open
packe100 opened this issue Jan 20, 2021 · 5 comments
Open

Even selected Items don't change state #162

packe100 opened this issue Jan 20, 2021 · 5 comments

Comments

@packe100
Copy link

packe100 commented Jan 20, 2021

Hi!
I have an angular 11 application with latest ng-material-multilevel-menu v 5.5.3.
I have a strange issue with my menu.

If I select any odd item, I obtain the expected behavior: the router navigates the link and the item switches to selected state (blue color).
If I select an even item the link is navigated but the item doesn't switch to selected state.

Here is menu data structure inside the component:

appitems = [
    {
      label: 'Home',
      link: '/home',
      icon: 'home',
      hidden: false
    },
    {
      label: 'Menu 1',
      icon: 'language',
      hidden: false,
      items: [
        {
          label: 'Item 1',
          link: '/page1',
          icon: 'language',
          hidden: false
        },
        {
          label: 'Item 2',
          link: '/page2',
          icon: 'business',
          hidden: false
        },
        {
          label: 'Item 3',
          link: '/page3',
          icon: 'store',
          hidden: false
        },
        {
          label: 'Item 4',
          link: '/page4',
          icon: 'ballot',
          hidden: false
        },
        {
          label: 'Item 5',
          link: '/page5',
          icon: 'widgets',
          hidden: false
        }
      ]
    },
];

config = {
    paddingAtStart: true,
    interfaceWithRoute: true,
    classname: 'side-nav-menu',
    highlightOnSelect: true,
    collapseOnSelect: true,
    rtlLayout: false
  };

This is the template snipped:

<ng-material-multilevel-menu [items]='appitems'
                             (selectedItem)="selectedItem($event)"
                             [configuration]='config'>
</ng-material-multilevel-menu>

Any idea about the solution of this problem would be much appreciated!
Thank you!

Max & Tonic

menu

@packe100
Copy link
Author

Good news!
I found the issue: switching the config param "interfaceWithRoute" to false, the menu started working as expected.
Unfortunately I don't know the reason... :(

@ShankyTiwari
Copy link
Owner

Hi @packe100 Can you please share the small repo so that I can see & work on it.

Thanks

@packe100
Copy link
Author

Hi @packe100 Can you please share the small repo so that I can see & work on it.

Thanks

Thanks @ShankyTiwari for your help.
At the moment I have only the full private repo on bitbucket.
I should fork a little one on github..

@shanurrahman-gcsns
Copy link

switching the config param "interfaceWithRoute" to false, the menu started working verified and its true

@victorbritoyi
Copy link

selectedListItem(event: MultilevelNode): void {
this.nodeExpandCollapseStatus = ExpandCollapseStatusEnum.neutral;
if(!event.hasChildren) {
this.currentNode = event;
}

if (!CommonUtils.isNullOrUndefined(event.dontEmit) && event.dontEmit) {
return;
}
if (event.items === undefined && (!event.onSelected || typeof event.onSelected !== 'function') ) {
this.selectedItem.emit(event);
} else {
this.selectedLabel.emit(event);
}
}

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

4 participants