dotnetcore / BootstrapBlazor

Bootstrap Blazor is an enterprise-level UI component library based on Bootstrap and Blazor.
https://www.blazor.zone
Apache License 2.0
2.71k stars 302 forks source link

TreeView javascript throw exception #4717

Open gmondin opened 4 days ago

gmondin commented 4 days ago

Is there an existing issue for this?

Describe the bug

HI, after update to a 9.0.0 version, my tree view started have a javascript error, apparently its work, but when I tried to debug, I get this error.

Screenshot 2024-11-22 062048

Expected Behavior

I would like not to have this error on debug.

Interactive render mode

Interactive WebAssembly (Client-side rendering (CSR) using Blazor WebAssembly)

Steps To Reproduce

I have a treeview in my page

Exceptions (if any)

No response

.NET Version

9

Anything else?

Screenshot 2024-11-22 062048

bb-auto[bot] commented 4 days ago

@gmondin Thank you for reporting. We will give triage later.

ArgoZhang commented 3 days ago

@gmondin could you upgrade to 9.0.1 try agian. if you have any questions please let me know.

gmondin commented 2 days ago

@ArgoZhang Hi, I just update to 9.0.1, but, I still have the same problem. options is undefined when enter to the method.

ArgoZhang commented 2 days ago

@gmondin could you submit a repro-project? I can't reproduce this issue here.

gmondin commented 1 day ago

Hi, I'm sorry, I cant share the project, but, I will copy the code:

razor

Tree Items="@_SideMenuItems" ShowIcon="true" ShowSkeleton="true" OnExpandNode="@OnClickMenu" OnTreeItemClick="@OnClickMenu" class="pi_tree_menu"

cs

[NotNull] List<TreeItem> _SideMenuItems { get; set; }

_SideMenuItems = await GetMenuItems(_menuItems.items);

    private async Task<List<TreeItem>> GetMenuItems(ItemMenu[] items, List<ItemMenu> listActivesMenu = null)
{
    List<TreeItem> res = new List<TreeItem>();
    if (_menuItems != null)
    {
        foreach (var item in items)
        {
            TreeItem mi = new TreeItem
                    {
                        Id = item.ID.ToString(),
                        Text = string.IsNullOrWhiteSpace(item.HotKey) ? item.Desc : $"{item.HotKey} - {item.Desc}",
                        Icon = item.Icon,
                        IsActive = listActivesMenu != null && listActivesMenu.Where(x => x.ID == item.ID).Any(),
                        CssClass = listActivesMenu != null && listActivesMenu.Where(x => x.ID == item.ID).Any() ? "activeMenu" : string.Empty,
                        IsCollapsed = !(item.items != null && item.items.Count() > 0 && listActivesMenu != null && listActivesMenu.Where(x => x.ID == item.ID).Any())
                    };

            if (item.items != null && item.items.Any() && item.items.Count() > 0) mi.Items = await GetMenuItems(item.items, listActivesMenu);
            res.Add(mi);
        }
    }
    return res;
}

private async Task OnClickMenu(TreeItem item)
{
        _NavigationManager.NavigateTo(myUrl);
}
ArgoZhang commented 1 day ago

@gmondin create a new demo project for repro this issue not share your project.