Clear Error
Collapse
Expand
Menu Focus Change (Deprecated)
Menu Select (Deprecated)
Menu Trigger Press (Deprecated)
Validation Error (Deprecated)
LWC Developer Guide
SLDS 1
SLDS 2
ui:menuSelect
Deprecated as of API version 47.0. Use lightning:select or lightning:combobox instead.
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.
1<aura:component>
2 <ui:menu>
3 <ui:menuTriggerLink aura:id="trigger" label="Contacts" />
4 <ui:menuList class="actionMenu" aura:id="actionMenu" menuSelect="{!c.handleSelect}">
5 <ui:actionMenuItem aura:id="item1" label="All Contacts" click="{!c.doSomething}" />
6 <ui:actionMenuItem aura:id="item2" label="All Primary" click="{!c.doSomething}" />
7 </ui:menuList>
8 </ui:menu>
9</aura:component>When a menu item is clicked, the click event is handled before the ui:menuSelect event.
1({
2 handleSelect: function (component, event, helper) {
3 var selected = event.getParam("selectedItem");
4
5 // returns label of selected item
6 var selectedLabel = selected.get("v.label");
7 },
8
9 doSomething: function (component, event, helper) {
10 console.log("do something");
11 },
12});If you’re using this event with a component other than ui:menuList, register the event first.
1<aura:registerEvent
2 name="menuSelect"
3 type="ui:menuSelect"
4 description="The event fired when a menu item is selected."
5/>| 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[] |