Menu Select (Deprecated)

ui:menuSelect

Deprecated as of API version 47.0. Use lightning:select or lightning:combobox instead.

::::::tabset{tabs='[ "Develop", "Specifications"]'}

:::::tab

This event is fired when you select a menu item on the ui:menuList component. To set a handler for the ui:menuSelect event, use the menuSelect attribute on ui:menuList.

The following example shows a menu with two list items. The handleSelect client-side controller action handles the ui:menuSelect event.

<aura:component>
  <ui:menu>
    <ui:menuTriggerLink aura:id="trigger" label="Contacts" />
    <ui:menuList class="actionMenu" aura:id="actionMenu" menuSelect="{!c.handleSelect}">
      <ui:actionMenuItem aura:id="item1" label="All Contacts" click="{!c.doSomething}" />
      <ui:actionMenuItem aura:id="item2" label="All Primary" click="{!c.doSomething}" />
    </ui:menuList>
  </ui:menu>
</aura:component>

When a menu item is clicked, the click event is handled before the ui:menuSelect event.

({
  handleSelect: function (component, event, helper) {
    var selected = event.getParam("selectedItem");

    // returns label of selected item
    var selectedLabel = selected.get("v.label");
  },

  doSomething: function (component, event, helper) {
    console.log("do something");
  },
});

If you're using this event with a component other than ui:menuList, register the event first.

<aura:registerEvent
  name="menuSelect"
  type="ui:menuSelect"
  description="The event fired when a menu item is selected."
/>

:::::

:::::tab

Attributes

Name Description Type Default Required
deselectSiblings Deselects the siblings of the currently selected menu item. boolean
focusTrigger Sets focus to menuTrigger. boolean
hideMenu Hides menu if set to true. boolean
selectedItem The menu item that's selected. component[]

:::::

::::::