ASP.NET Core MVC Controls | ComponentOne
Working with Controls / Input Controls / Menu / Work with Menu / Selection and Focus
In This Topic
    Selection and Focus
    In This Topic

    Sometimes, you might want an option to automatically select and focus the first item in the menu when it opens. This behavior can be achieved in the menu control by setting the AutoSelectOnFocus property to true.

    The AutoSelectOnFocus property sets a value that determines whether the first enabled item in the menu is automatically focused/selected in the dropdown. This provides appropriate navigation when accessibility tools are used. By default, the value of the AutoSelectOnFocus property is set to false.

    The following image showcases the first item in the menu as selected and in focus.

    The following code showcases the use of the AutoSelectOnFocus property. This example uses the data and the code used in Quick Start sample.

    View

    Index.cshtml
    Copy Code
    <c1-menu header="File" auto-select-on-focus="true" width="100px">
        <c1-menu-item header="New"></c1-menu-item>
        <c1-menu-item header="Open"></c1-menu-item>
        <c1-menu-item header="Save"></c1-menu-item>
        <c1-menu-item is-separator=true></c1-menu-item>
        <c1-menu-item header="Exit"></c1-menu-item>
    </c1-menu>