-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
I am currently working on a project using the ABP Framework with a Blazor front end, and I’ve encountered a challenge that I’m hoping you might be able to assist me with.
I am trying to update the main menu items dynamically, but unfortunately, the changes are not being rendered as expected.
I injected IMenuManager into my blazor page and use the following code to update my menu (Test submenu items in my case).
var mainMenu = await MenuManager.GetMainMenuAsync();
var testMenu = mainMenu.FindMenuItem("Test");
// Clear the existing menu items
testMenu.Items.Clear();
// Add the new menu items
foreach (var item in MyItems)
{
testMenu.AddItem(
new ApplicationMenuItem(
$"Test.{item.Name}",
item.Name,
url: $"/test/{item.Id}"
)
);
}
When I call the above method, the main menu does not reflect the updates. I suspect that I need to invoke StateHasChanged() on the ABP menu module (component), but I’m unsure how to access it.
I’ve searched through the ABP documentation and community forums, but I haven’t been able to find a solution to this issue.
Is there any workaround for this?
Thanks.