Completed
Last Updated: 21 Mar 2023 13:58 by ADMIN
Release 4.2.0 (26/04/2023)
Mathew
Created on: 10 Aug 2022 10:42
Category: Menu
Type: Bug Report
2
Disabled Menu items provide access to children with keyboard navigation

Hello,

If I disable a Menu item at runtime, it prohibits access to child items via the mouse, but still opens the child group of items if I use the keyboard navigation.

Here is a test page with a workaround included (which is to recreate the Menu).

<TelerikButton OnClick="@DisableItem">Disable Services item</TelerikButton>
<TelerikButton OnClick="@EnableItem">Enable Services item</TelerikButton>

@if (ShowMenu)
{
    <TelerikMenu Data="@MenuItems" />
}

@code {
    List<MenuItem> MenuItems { get; set; }

    bool ShowMenu { get; set; } = true;

    async Task DisableItem()
    {
        MenuItems.Find(x => x.Text == "Services").Disabled = true;

        MenuItems = new List<MenuItem>(MenuItems);

        // workaround start
        ShowMenu = false;
        await Task.Delay(1);
        ShowMenu = true;
        // workaround end
    }

    async Task EnableItem()
    {
        MenuItems.Find(x => x.Text == "Services").Disabled = false;

        MenuItems = new List<MenuItem>(MenuItems);
    }

    protected override void OnInitialized()
    {
        MenuItems = new List<MenuItem>()
    {
            new MenuItem()
            {
                Text = "Company",
                Items = new List<MenuItem>()
                {
                    new MenuItem()
                    {
                        Text = "Overview"
                    },
                    new MenuItem()
                    {
                        Text = "Events"
                    }
                }
            },
            new MenuItem()
            {
                Text = "Services",
                Items = new List<MenuItem>()
                {
                    new MenuItem()
                    {
                        Text = "Consulting"
                    },
                    new MenuItem()
                    {
                        Text = "Education"
                    }
                }
            }
        };

        base.OnInitialized();
    }

    public class MenuItem
    {
        public string Text { get; set; }
        public bool Disabled { get; set; }
        public List<MenuItem> Items { get; set; }
    }
}

0 comments