enableItems not working in Angular Menu

In my Angular Menu I'm trying to disable an option in the menu but it is not working. I have created a Stackblitz to reproduce the issue https://stackblitz.com/edit/angular-5mdywsmu-xassqaje?file=src%2Fapp.component.ts .

Notice in the example that when the menu is created I call the enableItems function with the value false to disable one of the options in the menu but that option is not disabled.

Is this a bug or is there something I'm missing?


3 Replies 1 reply marked as answer

YA YuvanShankar Arunagiri Syncfusion Team March 28, 2025 05:30 AM UTC

Hi Anthony,


We have reviewed your reported query with the menu component; based on our menu component architecture, we have created a new li element for every sub-menu opening action. So while handling the enable/disable-related action for the submenu, kindly handle it in the beforeOpen event of the Menu component. We have already provided the sample for enable/disable-related codes in our UG documentation. Refer to the below links and code snippet.


UG link: https://ej2.syncfusion.com/angular/documentation/menu/how-to/customize-menu-items#enable-or-disable-menu-items


<ejs-menu #menu [items]='menuItems' (created)='created()' (beforeOpen)='beforeOpen($event)'></ejs-menu>

….

public beforeOpen(args: BeforeOpenCloseMenuEventArgs): void {

    for (let i: number = 0; i < args.items.length; i++) {

      if (['1'].indexOf(args.items[i].id as string) > -1) {

          this.menu?.enableItems([args.items[i].id as string], false, true);

      }

  }


Sample link: https://stackblitz.com/edit/angular-5mdywsmu-wk21cphm?file=src%2Fapp.component.ts


Please let us know if you need any further assistance on this.


Regards,

YuvanShankar A


Marked as answer

AN Anthony March 28, 2025 11:28 PM UTC

I have confirmed that making the method call in the beforeOpen handler results in the expected behavior. Thanks.



PK Priyanka Karthikeyan Syncfusion Team April 2, 2025 01:08 PM UTC

Hi Anthony,

Thank you for the update. Please get back to us if you need any further assistance.

Regards,

Priyanka K




Loader.
Up arrow icon